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
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!
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.