Why doesn't the following code work? When I run it, I get 20 commas in the log (followed by the value of i, 101 on the next line), but I am expecting five rows of 20 commas. If I change it to v(i)=1, it works as expected, with multiple rows of 1 followed by a comma. [This is abstracted from a large program where missing values seem to messing up my output]
data _null_; array v(*) v1-v100; do i=1 to dim(v); v(i)=.; end; file log dsd ls=20 dlm="," ; put (_all_) (:); run;
It seems like a bug to me.
As a workaround, you could use a codification for missing values, for instance :
option missing="M";
It seems like a bug to me.
As a workaround, you could use a codification for missing values, for instance :
option missing="M";
I'm trying to read the data back into SAS using
input (_all_)( : );
(After first defining the variable list and informats using attrib statements).
So, to use your work around I have to add
missing M;
prior to the input statement. This works, though the missings are now read in as .M rather than generic missing (.). I then need to follow up with array loop to recode them to my preferred generic missing.
Thanks
PS I've sent this on to tech support.
Hello,
You can use a user defined informat to interpret M's as missing values.
proc format;
invalue v
"M"=.
other=best.
;
run;
option missing=".";
data test;
informat v1-v100 v. i best.;
infile log1 dlm="," dsd;
input (_all_) (:);
run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.