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):
Thank You for the explanation , but I can give the other number ( like 80) instead of 65
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.