- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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").
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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"
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
"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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
To be clear, this role only applies to the file name, not the file path. You can have a mixed case in your file path with no issue(see below). Only the file name must be lowercase
Even more interesting, this role is only for sas7bdat file, the other files(like csv, excel) do not follow it
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
When you ask SAS to reference a dataset the text you use in the code for the memname (the name of the member in a SAS library) can be in any case you want. But on UNIX SAS will look for and use a file with that membername (and the .sas7bdat extension) in lowercase only. Since the on the Unix file system filenames are case sensitive filenames with any uppercase letters will not be seen as datasets by SAS.
And yes when referencing other types of files like CSV files, (really any file other than SAS objects like datasets and catalogs and index files) then you do have to match the filename case used in the code with the filename case used in the file system.
Note that SAS probably also looks for datasets using lowercase filenames on Windows, but since on the Windows file system filenames are case insensitive it does not really matter.