SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

How to add next content based on defined variable?

Reply
Super Contributor
Posts: 297

How to add next content based on defined variable?

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

Super User
Posts: 5,257

Re: How to add next content based on defined variable?

Just a conditional assignment and an explicit output in a data step-

Data never sleeps
Super Contributor
Posts: 297

Re: How to add next content based on defined variable?

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

 

Ask a Question
Discussion stats
  • 2 replies
  • 239 views
  • 0 likes
  • 2 in conversation