I want to repeat the entore row in a SAS data set based on the following condition :
I have attached the screen shot on how the raw data looks like and what I need as output for Reg_number : 8765432:
Data I have:
Data I want
I tried using repeat function and SQL, however I was not fully successful, Appreciate your quick help on this.
Use a Data step with an explicit OUTPUT statement. Make sure to include an else output so that other records are also displayed.
If <condition> then do;
Do base_fund= 'add_silver' , 'add_bronze', ... 'Add_awesome';
Output;
End;
End;
Else output;
If by "repeat" you mean to duplicate a row with changes then the code should be:
Data want;
set have;
output; /* save original row */
if <condition> then do;
<do your changes>
output; /* with the changed data */
end;
run;
Data want; set have;
Output;
If duration le 4 then do;
Basefund=’add_silver’; output’
Basefund=’silver’; output’
Basefund=’add_gold’; output’
Basefund=’bronze’; output’
End;
JIm
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.