- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 01-24-2019 03:32 AM
(917 views)
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
1 REPLY 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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