DATA Step, Macro, Functions and more

Four level SAS name (libref/cat/dataset/etc).

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 5
Accepted Solution

Four level SAS name (libref/cat/dataset/etc).

Hi, I am confused about four level SAS names.

I have a program than runs proc report on a four level SAS name.

I read online four level SAS names are libref.catalog.entryname.entrytype.

I don't understand what entry name and type are, can anyone help?

Also, where does the dataset name come into it?

Thanks

Accepted Solutions
Solution
‎09-25-2015 05:06 PM
Super User
Super User
Posts: 7,039

Re: Four level SAS name (libref/cat/dataset/etc).

[ Edited ]
Posted in reply to iyerkaren

The periods are part of the macro code, not part of the name.

c_sample.rwa_p&pp.&yy._live

&pp. will resolve to the value of the PP macro variable

&yy. will resolve to the value of the YY macro variable.

So this code 

%let PP=ABC ;
%let YY=15 ;
%put c_sample.rwa_p&pp.&yy._live ;

willl write 

c_sample.rwa_pABC15_live

to the log.  There is only one period in the resulting value. 

 

The period is needed on the &YY reference to mark where the end of the macro name is.  Otherwise the macro processor would look for a macro variable named YY_LIVE instead of YY.   It is not required on the reference to PP since the & following PP will signal the end of the macro variable name.

View solution in original post


All Replies
Super Contributor
Posts: 345

Betreff: Four level SAS name (libref/cat/dataset/etc).

Posted in reply to iyerkaren

Please post the code using the four level name.

Occasional Contributor
Posts: 5

Re: Four level SAS name (libref/cat/dataset/etc).

Posted in reply to iyerkaren
Proc report data=c_sample.rwa_p&pp.&yy_live completerows completecols out=test (drop=_break_);
Occasional Contributor
Posts: 5

Re: Four level SAS name (libref/cat/dataset/etc).

Posted in reply to iyerkaren
Sorry I meant to type

c_sample.rwa_p&pp.&yy._live

Super User
Super User
Posts: 7,942

Re: Four level SAS name (libref/cat/dataset/etc).

Posted in reply to iyerkaren

What software are you running, this doesn't look like base SAS, perhap Enterprise Guide or something else?  Does the code work?  In base SAS it is always <library>.<dataset>

Solution
‎09-25-2015 05:06 PM
Super User
Super User
Posts: 7,039

Re: Four level SAS name (libref/cat/dataset/etc).

[ Edited ]
Posted in reply to iyerkaren

The periods are part of the macro code, not part of the name.

c_sample.rwa_p&pp.&yy._live

&pp. will resolve to the value of the PP macro variable

&yy. will resolve to the value of the YY macro variable.

So this code 

%let PP=ABC ;
%let YY=15 ;
%put c_sample.rwa_p&pp.&yy._live ;

willl write 

c_sample.rwa_pABC15_live

to the log.  There is only one period in the resulting value. 

 

The period is needed on the &YY reference to mark where the end of the macro name is.  Otherwise the macro processor would look for a macro variable named YY_LIVE instead of YY.   It is not required on the reference to PP since the & following PP will signal the end of the macro variable name.

Occasional Contributor
Posts: 5

Re: Four level SAS name (libref/cat/dataset/etc).

Posted in reply to iyerkaren
Ah that's probably why I'm confused. I didn't realise the base SAS/enterprise guide difference. I am new to enterprise guide. Still, does anyone know what the code refers to? Thanks.
Super User
Posts: 11,343

Re: Four level SAS name (libref/cat/dataset/etc).

[ Edited ]
Posted in reply to iyerkaren

That is not a 4 level name. Since there are macro variables involved (the && bits) the "." is a concatenator.

If there were two dots ".." in the code then the macro processor would resolve that to a . separating the names.

 

Something, possibly a prompt(?) or menu selection is building a name for you if you didn't create that code.

 

With c_sample.rwa_p&pp.&yy_live 

if there is something set so that a macro variable PP = DOG and a variable YY_LIVE=SHOE this would resolve to

c_sample.rwa_pDOGSHOE.  The first do does not have a possible macro variable before it but the second does.

 

 

Occasional Contributor
Posts: 5

Re: Four level SAS name (libref/cat/dataset/etc).

Posted in reply to iyerkaren
Thank you so much. No it's not my code I'm picking out data sources for work. Thanks!
🔒 This topic is solved and locked.

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

Discussion stats
  • 8 replies
  • 432 views
  • 3 likes
  • 5 in conversation