Suppose I have this table IN CAS:
I want to fill the blanks with the previous nonblank value for each column, by ID:
Normally in SAS I would use the proc expand, but since the proc expand is not CAS enabled, how would you do that in the easiest way as possible using CAS ACTIONS only (Viya 3.5)?
Unfortunately that code doesn't work in CAS:
cas session; libname P cas caslib="PUBLIC"; data P.have; input ID A B; datalines; 1 10 20 2 . 21 3 . . 4 11 . ; data P.temp / view = P.temp; set P.have; i = 1; run; data P.want (drop = i); update P.temp(obs=0) temp; by i; output; run;
95 data P.temp / view = P.temp; 96 set P.have; 97 i = 1; 98 run; ERROR: P.TEMP.VIEW cannot be opened because files of type VIEW are not supported in the P library. ERROR: Unable to save DATA STEP view P.TEMP.
Thanks! I adapted to work in CAS, and yes it works:
data P.want / single=yes; set P.have; by ID; retain aa bb; if a then aa = a; else a = aa; if b then bb = b; else b = bb; drop aa bb; run;
However if anyone knows if there are dedicated actions for these situations in Viya 3.5 or planned for Viya 4, that would be much appreciated!
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.