BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
iyerkaren
Fluorite | Level 6
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
1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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

8 REPLIES 8
andreas_lds
Jade | Level 19

Please post the code using the four level name.

iyerkaren
Fluorite | Level 6
Proc report data=c_sample.rwa_p&pp.&yy_live completerows completecols out=test (drop=_break_);
iyerkaren
Fluorite | Level 6
Sorry I meant to type

c_sample.rwa_p&pp.&yy._live

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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>

Tom
Super User Tom
Super User

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.

iyerkaren
Fluorite | Level 6
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.
ballardw
Super User

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.

 

 

iyerkaren
Fluorite | Level 6
Thank you so much. No it's not my code I'm picking out data sources for work. Thanks!

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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
  • 8 replies
  • 1663 views
  • 3 likes
  • 5 in conversation