How do I duplicate data but still process it? I know that you can use the output statement to create a duplicate record, but if you do any processing after this point it shows up as missing. You can see this in the Test dataset - the Runs field, created after the output statement, is blank for Smith's duplicated observation.
data have;
infile datalines dsd;
input Name : $9. Score1-Score3 Team ~ $25. Div $;
datalines;
Smith,12,22,46,"Green Hornets, Atlanta",AAA
Mitchel,23,19,25,"High Volts, Portland",AAA
Jones,09,17,54,"Vulcans, Las Vegas",AA
;
data test;
set scores;
if name = "Smith" then output;
Runs=sum(Score1,Score2,Score3);
output;
run;
data want;
infile datalines dsd;
input Name : $9. Score1-Score3 Team ~ $25. Div $ Runs $2.;
datalines;
Smith,12,22,46,"Green Hornets, Atlanta",AAA,80
Smith,12,22,46,"Green Hornets, Atlanta",AAA,80
Mitchel,23,19,25,"High Volts, Portland",AAA,67
Jones,09,17,54,"Vulcans, Las Vegas",AA,80
;
Just do the calculation before the output statement?
data test;
set have;
Runs=sum(Score1,Score2,Score3);
if name = "Smith" then output;
output;
run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.