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;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 720 views
  • 1 like
  • 3 in conversation