As the first step in the decommissioning of sasCommunity.org the site has been converted to read-only mode.
Here are some tips for How to share your SAS knowledge with your professional network.
PUT Statement with DSD and Missing Values
When using a PUT statement to output data in a DATA step and the DSD option is coded on the FILE statement, and there are missing values, the missing values will not appear in the output records. Instead, the delimiters preceding and following the missing value will be adjacent to each other (or adjacent to the start or end of the record).
This behavior is reasonable, and reciprocates the effect of the DSD option on the INFILE statement, but does not appear to be documented.
data demo; retain a 1 b c . d 4 w 'W' x y ' ' z 'Z' ; run;
data _null_; set demo; file 'demo.csv' delimiter=',' dsd; format a b c d best12. w z y z $1.; if _n_ = 1 then put 'a,b,c,d,w,x,y,z'; put a @; put b @; put c @; put d @; put w $ @; put x $ @; put y $ @; put z $ ; run;
This DATA step is essentially like the one generated by PROC EXPORT with CSV as the DBMS.
To reveal the result, run:
data _null_; infile 'demo.csv'; input; list; run;
RULE: ----+----1----+----2 1 a,b,c,d,w,x,y,z 15 2 1,,,4,W,,,Z 11
If the DSD option is removed, the outcome is instead:
RULE: ----+----1----+----2 1 a,b,c,d,w,x,y,z 15 2 1,.,.,4,W, , ,Z 15
If the DSD option is in effect and the MISSING system option is set to some character other than the dot, numeric missing values will appear explicitly, in the form of the chosen character.