
#SAS PMENU UCLA CODE#
Maintenance of code should always be a factor in how you write your code (in my opinion).Īlthough I will answer your question here, my first recommendation is that you do not add a NEW question on a NEW topic to an old posting. With my version of the code, using the LIBNAME statement, I only have to change the LIBNAME statement in order to be able to point to a changed location for the data. This program now has to be changed in every location where the physical file name is referenced. Proc print data='c:\mydata\info.sas7bdat' You can, of course, just use the fully qualified name in code.so this should work for you (it worked for me): So it would be good for you to understand what a SAS library is and how it is used in a 2 level name. That is how most SAS programs are written. Title 'After copying the file and creating NEWVAR' īut, you do not have to use the LIBNAME.DATA convention. To make a copy of info.sas7bdat or to use it in a procedure, you would need to use the 2 level name do this: Title 'What datasets are in this location?' Pointing to the library is only good for some procedures: You have to use a 2 level name to point to the individual dataset within the library. Any SAS datasets in that location will now be accessible to you. The LIBNAME statement will provide your SAS session with the high level location of the data. In this case, it is something silly like WOMBAT, but it can be any name, as long as the name conforms to the SAS naming conventions (which I leave for you to look up in the documentation).

The LIBNAME statement establishes a "nickname" or libref (library reference) that gives SAS a high leval name to use. Your SAS session can't read data until is knows where to look for data. Next you will need to "plug into" the data - just like you plug your lamp into the electrical outlet - the lamp won't turn on until is has power. Which means that the file is stored in a physical location ( c:\mydata) on your machine and the name of the file is info.sas7bdat. Let's assume the physical name and location of your file is: You should NOT need to import a SET statement or DATA= option should be sufficient, if you have the syntax correct.
