BookmarkSubscribeRSS Feed
nit123
Obsidian | Level 7

are the variables and file names in SAS case sensitive?

 

 

data set;
    set sasdata .chemists;
    if jobcode = 'Chem2'
        then description = 'Senior Chemist';
    else description = 'Unknown';
run;

A value for the variable JOBCODE is listed below:

JOBCODE
chem2

 

output:  ?

 

 

the following file downloaded from SAS->help->learn sas programming

 

proc print data=clinic.stress2;
run;

 

/* modified file name */

proc print data=clinic.Stress2;
run;

 

output is same for both print statements

5 REPLIES 5
PGStats
Opal | Level 21

Keep on experimenting! You will find that file names, library names, variable names and language elements are NOT case sensitive but that operations on string variables (e.g. name = "John") ARE case sensitive. Thus, when you want to make string operations case insensitive, you must take precautions (e.g. upcase(name) = "JOHN").

PG
monei011monei01
Calcite | Level 5

I have found one place where case sensitivity occurs. I have a dataset in a data library and from within SAS EG I right click on the dataset and choose rename. If I rename the dataset to a name that includes uppercase characters, SAS EG can no longer "open" the dataset using right click "open"

Kurt_Bremser
Super User

Within the file system, the names have to be all lowercase; within in SAS code, the names are case insensitive, with an exception: if you need to query the dictionary tables, LIBNAME and MEMNAME are all uppercase.

monei011monei01
Calcite | Level 5

"Within the file system, the names have to be all lowercase" is not entirely true. I can create a file in both unix and widows at the operating system level where the name can be mixed case, all lower case, or all uppercase.  Under unix I can create a file name that includes special characters and blanks (probably not a practice that is sympathetic to other users or unix command users!). It is just that SAS has some expectations about what the name of a file that is a SAS dataset should be called and perhaps what the case of the name is on disk. SAS / EG allows you to see two views of a dataset. One is the view of the dataset as a member of a SAS data library, and one as a view of the file in the file system. The library view presents all dataset names as uppercase, regardless of what their physical file name is on disk with extension sas7bdat. This is the same in SAS Studio under SAS Viya. The File view in SAS / EG shows the actual file name including the .sas7bdat extension. SAS / EG also uses the same dialogue of choices you can access from a right click on the object in either view. If you deliberately rename the dataset file name in the file view so that its name includes uppercase characters, then it becomes un-openable in SAS/EG. But this only happens if there is not a libname assigned to that same directory. Very particular I know, but a trap that can catch you if you are not careful.  SAS dates from before the existence of either Windows or Unix. It has not become more relaxed and  flexible in this area of naming objects as the operating systems have evolved to provide a better user experience.

Kurt_Bremser
Super User

Of course you can have mixed case in UNIX filenames, but SAS won't recognize those. It will find them as .sas7bdat files and show them in a library listing, but won't be able to open them as datasets.

This is what I meant.

 

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
  • 5 replies
  • 17682 views
  • 1 like
  • 4 in conversation