BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
BruceBrad
Lapis Lazuli | Level 10

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;

 

1 ACCEPTED SOLUTION

Accepted Solutions
gamotte
Rhodochrosite | Level 12

It seems like a bug to me.

 

As a workaround, you could use a codification for missing values, for instance :

 

option missing="M";

View solution in original post

3 REPLIES 3
gamotte
Rhodochrosite | Level 12

It seems like a bug to me.

 

As a workaround, you could use a codification for missing values, for instance :

 

option missing="M";

BruceBrad
Lapis Lazuli | Level 10

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.

gamotte
Rhodochrosite | Level 12

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;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1224 views
  • 1 like
  • 2 in conversation