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

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;

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisNZ
Tourmaline | Level 20

> 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;

 

View solution in original post

2 REPLIES 2
ChrisNZ
Tourmaline | Level 20

> 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;

 

Stalk
Pyrite | Level 9

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;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 2 replies
  • 426 views
  • 0 likes
  • 2 in conversation