How can I create date as well as unit for all the combinations. What's wrong with this code?
Data dummy;
date="&start."d;
do while (date<="&enddt."d);
output;
date=intnx('day', date, 1, 's');
end;
format date date9.;
array unit[3] $ '45' '55' '65';
do i=1 to 3;
unit = unit[i];
end;
> What's wrong with this code?
Its formatting for sure.
Also we don't know what result you expect. the second loop does nothing as no output statement is provided.
I suppose you might want to put the second loop inside the first one maybe?
data DUMMY;
array UNITS[3] $ '45' '55' '65';
do DATE="&startdt"d to "&enddt"d;
do I=1 to dim(UNITS);
UNIT= UNITS[I];
output;
end;
end;
format DATE date9.;
run;
> What's wrong with this code?
Its formatting for sure.
Also we don't know what result you expect. the second loop does nothing as no output statement is provided.
I suppose you might want to put the second loop inside the first one maybe?
data DUMMY;
array UNITS[3] $ '45' '55' '65';
do DATE="&startdt"d to "&enddt"d;
do I=1 to dim(UNITS);
UNIT= UNITS[I];
output;
end;
end;
format DATE date9.;
run;
Thank you. It worked with parenthesis
data DUMMY;
array UNITS[3] $ ('45' '55' '65');
do DATE="&startdt"d to "&enddt"d;
do I=1 to dim(UNITS);
UNIT= UNITS[I];
output;
end;
end;
format DATE date9.;
run;
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 save with the early bird rate—just $795!
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.