id name salary
1 ash 1500
2 ani *
3 ayu 2000
4 shw *
5 ami 1200
6 su *
in the above question I want to replace * with just previous value. what would be the syntax in sas?
e.g In 2nd observation * is replaced by 1500 and in 4th observation * is replaced by 2000 and so on.
@ashkum wrote:
salary is nuemric here
Then just edit RW9's code accordingly: Delete (and forget) $200, use ifn in place of ifc and replace "*" by . (the period denotes a numeric missing value) or whatever numeric value was displayed as an asterisk (assuming it was always the same value).
Something like:
data want (drop=lst); set have; retain lst $200; lst=ifc(salary ne "*",salary,lst); salary=ifc(salary="*",lst,salary); run;
Note not tested, I assume salary is character as * is not numeric, post test data in the form of a datastep in future.
salary is nuemric here
Numeric variables cannot hold the symbol *, therefore either the variable is character or you have changed the missing option. Either way, this is why we always ask for test data in the form of a datastep to avoid these needless backwards and forwards guessing your data.
@ashkum wrote:
salary is nuemric here
Then just edit RW9's code accordingly: Delete (and forget) $200, use ifn in place of ifc and replace "*" by . (the period denotes a numeric missing value) or whatever numeric value was displayed as an asterisk (assuming it was always the same value).
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 lock in 2025 pricing—just $495!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.