SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Nietzsche
Lapis Lazuli | Level 10

Hi, In the official SAS specialist prep guide, page 46 on reading a SAS data set to create another data set, here is the screenshot.

Nietzsche_4-1667598338233.png

 

Nietzsche_3-1667597793298.png

 

I do understand the purpose of line 2 is to create a library where I can store the MALES dataset. However, there is no file or folder called "Men50" in the   'C:\Users\Student1\cert\' directory.  The book does NOT tell us to create a folder called "Men50" before you use LIBNAME statement to reference it.

 

So when I ran the code, I got an error even though I can see that MEN50 library was successfully created by SAS. So my question is, we always need to create the folder or make sure it exist in the physical file path before using LIBNAME to create a library for it?

 

 

Nietzsche_0-1667597538093.png

 

SAS Base Programming (2022 Dec), Preparing for SAS Advanced Programming (Cancelled).
1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

The folder you have circled on the left is a LIBREF and not an operating system directory.

To see the files and directories that exist on the computer where SAS is running use the Files and Folders panel instead of the Libraries panel.  (Don't ask me why they call directories folders.)

Remember that on Unix filenames (directories are just special files that hold information about the files that exist in them) are case-sensitive.  So a file named MEN50 would be a different file than one named Men50 or men50 or meN50.

View solution in original post

4 REPLIES 4
Tom
Super User Tom
Super User

The folder you have circled on the left is a LIBREF and not an operating system directory.

To see the files and directories that exist on the computer where SAS is running use the Files and Folders panel instead of the Libraries panel.  (Don't ask me why they call directories folders.)

Remember that on Unix filenames (directories are just special files that hold information about the files that exist in them) are case-sensitive.  So a file named MEN50 would be a different file than one named Men50 or men50 or meN50.

Nietzsche
Lapis Lazuli | Level 10

I thought SAS convert all file names and variable names to upper case anyway.

SAS Base Programming (2022 Dec), Preparing for SAS Advanced Programming (Cancelled).
Reeza
Super User

@Nietzsche wrote:

I thought SAS convert all file names and variable names to upper case anyway.


SAS data set names and variable names, but not file names and paths, which are system dependent. SAS code is case insensitive. 

And it depends on the underlying OS settings. Windows is case insensitive, but Linux is usually a case sensitive system. 

FYI - this is typically true in many programming tools not just a SAS feature. 

 

 

Reeza
Super User

So my question is, we always need to create the folder or make sure it exist in the physical file path before using LIBNAME to create a library for it?

 


It depends on your option setting. 

There's an option in SAS called DLCREATEDIR & NODLCREATEDIR

 

DLCREATEDIR

specifies to create a directory for a SAS library that is named in a LIBNAME statement if the directory does not exist.

Restriction If the path specified in the LIBNAME statement contains multiple components, SAS creates only the final component in the path. If any intermediate components of the path do not exist, SAS does not assign the specified path. For example, when the code libname mytestdir ‘c:\mysasprograms\test’ executes, and c:\mysasprograms exists, SAS creates the test directory. If c:\mysasprograms does not exist, SAS does not create the test directory.

NODLCREATEDIR

specifies not to create a directory for a SAS library that is named in a LIBNAME statement.

 

 

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 2534 views
  • 3 likes
  • 3 in conversation