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!
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.
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.
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));
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.
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.