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

I have 

 

Date
01-Jan-18
02-Jan-18
03-Jan-18
04-Jan-18
05-Jan-18
06-Jan-18
07-Jan-18
08-Jan-18
09-Jan-18

10-Jan-18

 

I want to repeat the above dates for some new values A,B,C.

 

So I want: 

ValueDate
A01-Jan-18
B01-Jan-18
C01-Jan-18
A02-Jan-18
B02-Jan-18
C02-Jan-18
A03-Jan-18
B03-Jan-18
C03-Jan-18
A04-Jan-18
B04-Jan-18
C04-Jan-18
A05-Jan-18

 

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

data have;
input Date :date9.;
format Date date9.;
cards;
01-Jan-18
02-Jan-18
03-Jan-18
04-Jan-18
05-Jan-18
06-Jan-18
07-Jan-18
08-Jan-18
09-Jan-18
10-Jan-18
;

data want;
set have;
do value='A','B','C';
output;
end;
run;

View solution in original post

4 REPLIES 4
novinosrin
Tourmaline | Level 20

data have;
input Date :date9.;
format Date date9.;
cards;
01-Jan-18
02-Jan-18
03-Jan-18
04-Jan-18
05-Jan-18
06-Jan-18
07-Jan-18
08-Jan-18
09-Jan-18
10-Jan-18
;

data want;
set have;
do value='A','B','C';
output;
end;
run;
kz134
Obsidian | Level 7

Thanks so much. What if I have another new set of values (C,D,E). Can I fit both into one code? or Do I have to do it twice? So I want:

 

Value2ValueDate
CA01-Jan-18
DA01-Jan-18
EA01-Jan-18
CB01-Jan-18
DB01-Jan-18
EB01-Jan-18
CC01-Jan-18
DC01-Jan-18
EC01-Jan-18
CA02-Jan-18
DA02-Jan-18
EA02-Jan-18
CB02-Jan-18
DB02-Jan-18
EB02-Jan-18
novinosrin
Tourmaline | Level 20

Nest it like this--

 

data want;
set have;
do value='A','B','C';
 do value2='C','D','E';
output;
end;
end;
run;
Astounding
PROC Star

If your list of values (A, B, C) is long, it might be more practical to store them in a data set and use SQL:

 

proc sql;

create table want as select * from date_table, value_table

order by date value;

quit;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 4 replies
  • 1369 views
  • 1 like
  • 3 in conversation