In SAS Prep guide, how it defined id=1147 is age 65 (it could be some # in age)..please explain
data work.clean_data;
set cert.pats;
gender=upcase(Gender);
if Gender='G' then Gender='M';
if id=1147 then age=65;
else if id=5277 then age=75;
run;
proc print data=work.clean_data;
run;
The value of ID comes from your source table cert.pats.
The code then has a condition which tests the value of ID (if id=1147). If the value of ID coming from your source table is 1147 then the condition becomes true and the bit after THEN gets executed. So here a value of 65 gets assigned to variable age overwriting whatever value age had before. The result gets at the end of the data step written to output table work.clean_data.
Hi @souji
Please compare the two datasets below (on the left, the initial dataset cert.pats; on the right the new one that has been created):
cert.pats
work.clean_data
Thank You for the explanation , but I can give the other number ( like 80) instead of 65
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.