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;
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.
The section
SAS Name Literals |
https://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#a000998953.htm
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.
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?
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.
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).
Thank you so much for all of your input.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.