BookmarkSubscribeRSS Feed
Almoha
Calcite | Level 5

Hi All,

 

i have the following data, for every on record i need to create two records with stdy and endy values populated under col1 and values in res must be populated under res1 as follows

 

any suggestions?

 

This is what i have 

sub stdy endy res
111 1 7 10
111 8 10 20
111 11 13 20
111 15 20 40
222 12 17 70
222 18 30 70

 

 

the final output
sub col1 res1
111 1 10
111 7 10
111 8 20
111 10 20
111 11 20
111 13 20
111 15 40
111 20 40
222 12 70
222 17 70
222 18 70
222 30 70

 

Thanks

 

2 REPLIES 2
PaigeMiller
Diamond | Level 26
data want;
    set have;
    col1=stdy;
    output;
    col1=endy;
    output;
    keep sub col1 res;
run;
--
Paige Miller
novinosrin
Tourmaline | Level 20
data have;
input sub stdy endy res;
cards;
111 1 7 10
111 8 10 20
111 11 13 20
111 15 20 40
222 12 17 70
222 18 30 70
;

data want;
set have;
do col1=stdy,endy;
output;
end;
drop stdy endy;
run;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 535 views
  • 1 like
  • 3 in conversation