BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
katie80
Fluorite | Level 6

HI, I have a large database that needs to be manipulated. I want to convert the data that looks like this:

 

iddate1date2var1var2
12005200853
22006200812

 

to something that looks like this:

 

iddate1date2date3var1var2
120052008200553
120052008200653
120052008200753
120052008200853
220062008200612
220062008200712
220062008200812

 

Basically, I want to convert each observation into id-years.

 

what is the best and most efficient way to do this?

 

Thanks!

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

If I understand what you are attempting;

Data want;
   set have;
   do date3 = date1 to date2;
        output;
   end;
run;

View solution in original post

3 REPLIES 3
ballardw
Super User

If I understand what you are attempting;

Data want;
   set have;
   do date3 = date1 to date2;
        output;
   end;
run;
katie80
Fluorite | Level 6

Thank you! I'll try that!

Jim_G
Pyrite | Level 9

data one;
input id: date1: date2: var1: var2:;
dur=date2-date1+1; date3=date1;
do x=1 to dur;
output;
date3+1;
end;
cards;
1 2005 2008 5 3
2 2006 2008 1 2
;
proc print; run;

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 1130 views
  • 0 likes
  • 3 in conversation