DATA Step, Macro, Functions and more

colon wildcard doesn't work in format statement

Accepted Solution Solved
Reply
New Contributor
Posts: 3
Accepted Solution

colon wildcard doesn't work in format statement

I am trying to create a date dimension table. Here is my code:

data date_dim;

     format date: date9.;

     do date='01JAN1990'd to '31DEC2089'd;

          date_yr_begin=intnx('Year', date, 0);

          output;

     end;

run;

The formatting does not work, however when I use the format statement with the variable names made expliciy, it does work. What's wrong?


Accepted Solutions
Solution
‎06-20-2013 11:57 AM
Respected Advisor
Posts: 3,777

Re: colon wildcard doesn't work in format statement

move the format to AFTER the variables are defined.

View solution in original post


All Replies
Respected Advisor
Posts: 3,777

Re: colon wildcard doesn't work in format statement

When the FORMAT statement compliled there are no varaibles that begin with DATE.  Think about it.

New Contributor
Posts: 3

Re: colon wildcard doesn't work in format statement

what about date_yr_begin?

Solution
‎06-20-2013 11:57 AM
Respected Advisor
Posts: 3,777

Re: colon wildcard doesn't work in format statement

move the format to AFTER the variables are defined.

New Contributor
Posts: 3

Re: colon wildcard doesn't work in format statement

OK, I get it. Put format at the end. Thx

Respected Advisor
Posts: 3,124

Re: colon wildcard doesn't work in format statement

if you have difficulty understanding DN's precise answer, here is one in action: move your format statement after the loop.

Haikuo

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 249 views
  • 3 likes
  • 3 in conversation