I have a table that looks like this and I want a the variable status to be split into two with one variable containing only "1" and the 2nd variable containing "2 and 3"
data have;
input ID Status;
datalines;
1 1
1 3
1 1
1 1
2 1
2 3
2 1
3 1
3 2
;
data want;
set have;
if status = 1 then _1stStatus = Status;
else if Status in (2, 3) then _2ndStatus = Status;
drop Status;
run;
It might help to describe how you intend to use the reshaped data. You may be adding unneeded complexity with additional variables.
Data want;
set have;
if status = 1 then Status1 = 1;
else if status in (2,3) then status2 = status;
run;
maybe. "1st status" is not legal for variable names.
If you no longer want the Status variable in the data set then drop it.
SAS Innovate 2025: Register Now
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9. Sign up by Dec. 31 to get the 2024 rate of just $495. Register now!