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

Hello:

 

I have the follow codes, what is the n used for after "April" ?  Why the test have double quotation marks?  Thanks.

 

PROC CONTENTS DATA=work."April"n 
OUT=AprilOut NOPRINT;
RUN;

 

1 ACCEPTED SOLUTION

Accepted Solutions
ewv
Obsidian | Level 7 ewv
Obsidian | Level 7

That looks like a SAS name literal. From the following paper 

 

"Name literals are most useful when accessing databases (and Excel spreadsheets) that may have non-standard column names. (for example, they might contain a space or an ampersand.)"

 

'Total Monthly Sales'n would be another example of a name literal, since it contains spaces.

 

Literals can use either single or double quotes. I'm not sure why they are using a name literal for "April" since it doesn't have any special characters, but it shouldn't hurt to use it either way.

View solution in original post

7 REPLIES 7
Kurt_Bremser
Super User

@ybz12003 wrote:

Hello:

 

I have the follow codes, what is the n used for after "test" ?  Why the test have double quotation marks?  Thanks.

 

PROC CONTENTS DATA=work."April"n 
OUT=AprilOut NOPRINT;
RUN;

There is no "test" in your code, and the name literal "April"n is not necessary, as April is a valid V7 SAS name.

ybz12003
Rhodochrosite | Level 12

You are right, I type the wrong word.  I should have use "April" instead of "test".

ewv
Obsidian | Level 7 ewv
Obsidian | Level 7

That looks like a SAS name literal. From the following paper 

 

"Name literals are most useful when accessing databases (and Excel spreadsheets) that may have non-standard column names. (for example, they might contain a space or an ampersand.)"

 

'Total Monthly Sales'n would be another example of a name literal, since it contains spaces.

 

Literals can use either single or double quotes. I'm not sure why they are using a name literal for "April" since it doesn't have any special characters, but it shouldn't hurt to use it either way.

ballardw
Super User

Generally an n used that way indicates use of a name literal. If the SAS option VALIDVARNAME is set to ANY then the names of variables may contain characters that are not normally acceptable. The quotes enclose the text as one of the characters that might occur in these names is a space. The n immediately after indicates name literal as the d does for dates such as "01JAN2018"d. The quotes could be single or double.

 

The option VALIDMEMNAME set to EXTEND does similar for Member names: data sets, data views or item stores.

 

The intent is basically to allow working with the names of things in external databases that allow such extra characters.

 

Personally, I find it a chore to work with and rename things as soon as practical to standard SAS names.

ybz12003
Rhodochrosite | Level 12

So I come up a question.   There are several datasets in my work folder, which including "April", "April_first", "April_middle", "April_end".  When I use proc content statement, does it mean I am looking for all the dataset containing "April", or just the file "April"?

Tom
Super User Tom
Super User

For PROC CONTENTS it is just the single dataset named.

But you can use the special token _ALL_ and it report on all of the datasets in the library.

proc contents data=mylib._all_ noprint out=contents; run;

You could then filter the output data based on the member name if you wanted the information for some of them.

data want ;
  set contents;
  where upcase(memname) like 'APRIL%';
run;
ybz12003
Rhodochrosite | Level 12

Thank you for all of the thoroughly explanation, step by step.   It's very helpful for me to understand.   Woman Happy

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 7 replies
  • 1127 views
  • 5 likes
  • 5 in conversation