Hello,
I have columns in Excel which have blank values. After importing to SAS they all now have a dot as shown below in the "have "dataset. Now the requirement is to subtract all these variables from 4 as shown. After performing the calculation to my surprise i still have missing values instead of 4. Did i miss anything?
data have
PAL1 PAL2 PAL3 PAL4
. . . .
run;
data Want;
set have;
paL1_=4-pal1;
pal2_=4-pal2;
pal3_=4-Pal3;
pal4_=4-pal4;
run;
Thank you
Simple calculations involving missing values will result in missing values; the log (Maxim 2) alerts you to that.
The sum() function will count missing values as zero, so you can use it here:
data have;
input pal1-pal4;
cards;
. . . .
;
run;
data want;
set have;
pal1_ = sum(4,-pal1);
pal2_ = sum(4,-pal2);
pal3_ = sum(4,-pal3);
pal4_ = sum(4,-pal4);
run;
proc print data=want noobs;
run;
Result:
pal1 pal2 pal3 pal4 pal1_ pal2_ pal3_ pal4_ . . . . 4 4 4 4
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
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.