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

Code is

 


libname mydata '/sas/prod/datamarts/rel/data/trans/';


data trans.loss;

%let data_set = trans.loss;
%let id = %sysfunc(open(trans.loss));
%let create_date = %sysfunc(attrn(&dsid,crdte));
%let dt = %sysfunc(datepart(&create_date),yymmdd10.);
%let close_flag = %sysfunc(close(&id));

 

But I get the following error; 

 

31 %let create_date = %sysfunc(attrn(&dsid,crdte),yyyymm.);
SYMBOLGEN: Macro variable DSID resolves to 0
WARNING: Argument 1 to function ATTRN referenced by the %SYSFUNC or %QSYSFUNC macro function is out of range.
NOTE: Mathematical operations could not be performed during %SYSFUNC function execution. The result of the operations have been set
to a missing value.

 

Any idea why it can't interpret crdte as a date?

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
maguiremq
SAS Super FREQ

Are you even defining &dsid? I see you that you define &id. Use that instead of &dsid in your attrn argument?

 

I'm not familiar with all that you're doing here. Troubleshooting beyond what I see above is beyond my comprehension.

 

I'm also confused why you're defining macro variables in a DATA step. Maybe also beyond my knowledge.

View solution in original post

4 REPLIES 4
maguiremq
SAS Super FREQ

Are you even defining &dsid? I see you that you define &id. Use that instead of &dsid in your attrn argument?

 

I'm not familiar with all that you're doing here. Troubleshooting beyond what I see above is beyond my comprehension.

 

I'm also confused why you're defining macro variables in a DATA step. Maybe also beyond my knowledge.

fgasdg
Calcite | Level 5
You're right... I was testing, and forgot to change &dsid back to &id..

that did it! Thanks!
japelin
Rhodochrosite | Level 12

try changing follows.

%let id = %sysfunc(open(trans.loss));
%let close_flag = %sysfunc(close(&id));

%let dsid = %sysfunc(open(trans.loss));
%let close_flag = %sysfunc(close(&dsid));
ballardw
Super User

What value do you get from

%let id = %sysfunc(open(trans.loss));

 

The place you are using &DSID expects an identifier from opening a file. You do not show any such code setting DSID. Did you mean to use &id?

 

The message

31 %let create_date = %sysfunc(attrn(&dsid,crdte),yyyymm.);
SYMBOLGEN: Macro variable DSID resolves to 0

tells you there is no identifier for a set assigned with DSID, so not set is open to read the attrn or any other function from that set.

 

When you start the code with:

data trans.loss;

you have placed the data set into write mode. So may be locked when the macro code executes. If you are going to manipulate things in macro code then do not mix with a data step. That way leads to madness quite often.

 

You should describe what you are attempting to do as I strongly suspect macro code is not needed.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 1072 views
  • 0 likes
  • 4 in conversation