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

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

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
  • 1193 views
  • 1 like
  • 2 in conversation