Hello, all:
My oringinal data set has "MSM" in variable "Risk" corespored to "Man" in variable "Race". Now, I would like to add one more "All" in variable "Race" when there are either "MSM" or "MSM-B" in variable "Risk". The final format example is shown below. How to approach this? Please help. Thanks.
Oringinal format:
Risk Race
MSM Man
MSM-B Man
Final format:
Risk Race
MSM All
MSM Man
MSM-B All
MSM-B Man
Just a conditional assignment and an explicit output in a data step-
I wrote the code below
Data A;
set B;
if RISK in ('MSM', 'MSM-B') then RACE='Man';
run;
I got the result for replacing the "All" with "Man". However, I couldn't get extra line for "All". How to get "All" and "Man" together to corresponded to "MSM" and "MSM-B"?
Oringinal format:
Risk Race
MSM All
MSM-B All
My SAS format:
Risk Race
MSM Man
MSM-B Man
The final format I would like to modify is:
Risk Race
MSM All
MSM Man
MSM-B All
MSM-B Man
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.