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 following codes.   I found out the proc content didn't work when I remove the n behind the "18RSV".   Could someone let me know why?  Thanks.

 

LIBNAME RSV OLEDB 
		provider="sqloledb" 
		properties=("Data Source"="SQL\2018"
					"Persist Security Info"="True" 
					"User ID"="test" 
					"Password"="&pin" 
					"Initial Catalog"="RSV")
		schema=dbo;

PROC CONTENTS DATA=RSV."18RSV"n OUT=RSV18 NOPRINT;RUN;
1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

The n means the string is a named literal.  It is used for strings which are not SAS compatible, often used with sources like Excel which have no rules.  In your given example dataset names cannot start with a number, so you need to use named literal.  This:

OUT=18RSV

Will not work, should give you an error as name cannot star with number.  Also avoid coding all in uppercase, its really hard to read. 

View solution in original post

7 REPLIES 7
novinosrin
Tourmaline | Level 20

The section 


SAS Name Literals

 

 

 

Definition of SAS Name Literals in the following link may help

 

https://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#a000998953.htm

 

 

Reeza
Super User
Because otherwise SAS reads that as a string not as a data set name. The letters after denote different things. An n means a name literal, a d means a date, dt means datetime, and t means time. The data set is not a valid name because it starts with a number.
RW9
Diamond | Level 26 RW9
Diamond | Level 26

The n means the string is a named literal.  It is used for strings which are not SAS compatible, often used with sources like Excel which have no rules.  In your given example dataset names cannot start with a number, so you need to use named literal.  This:

OUT=18RSV

Will not work, should give you an error as name cannot star with number.  Also avoid coding all in uppercase, its really hard to read. 

ybz12003
Rhodochrosite | Level 12

The code wasn't created by me, but someone else.  I am trying to figure out why he wrote this.   So from your feedback, the n is used because the dataset "18RSV" starting with number? 

mkeintz
PROC Star

Yes.

 

If your data source wants, he could prefix the name with an underscore, which might preserve the naming properties he/she wants while allowing you to dispense with the N and the quotes.

 

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
SuryaKiran
Meteorite | Level 14

For any of the SAS names that are not valid have to be in this way(string within quotation marks, followed by the upper- or lowercase letter n)

 

 

Thanks,
Suryakiran
ybz12003
Rhodochrosite | Level 12

Thank you so much for all of your input. Smiley Happy

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 603 views
  • 3 likes
  • 6 in conversation