How To Create Permanent Dataset In Sas
Temporary & Permanent SAS Datasets & the Libname Statement
SAS datasets can be temporary or permanent.
- Temporary SAS datasets only exist during the current SAS session.
- Permanent SAS datasets are saved to a location on the computer and exist after exiting SAS.
Unless otherwise specified to be permanent, SAS considers all datasets to be temporary.
SAS calls the directories that contain datasets libraries . To create a library, use a libname statement . A libname statement performs 2 important tasks:
- It creates and names the new SAS library
- It links the new SAS library to a directory on the computer.
Once a SAS library and computer directory link have been created using the libname statement, a permanent SAS data set can be:
- saved to the computer directory or
- imported from the computer directory for use in SAS.
A SAS data set name has the library name before the period and the data set name after the period.
For example, lib.ds indicates that data set ds is in library lib. In the directory linked to the library lib, there will be a (permanent) data set called ds.sas7bdat . [The extension sas7bdat is just a convention that SAS uses for permanent data sets.]
Example:
Note: The 'dixonmassey' data set is from Dixon WJ and Massey FJ Jr: Introduction to Statistical Analysis, Fourth Edition, McGraw Hill Book Company, 1983.
Use a libname statement to establish the library perm and to link it to the F drive. Then save the data set dixonmassey as a permanent SAS data set on the F drive. The statement data perm.dixonmassey creates a SAS data set called "dixonmassey.sas7bdat" located in the F drive.
The statement below creates a SAS library named "perm" and then links "perm" to the F drive.
libname perm 'F:\';
The next statement calls from the library called "perm" and selects the data set called "dixonmassey."
Importing a Data set
Example:
Import the permanent SAS data set, copy_cd4count , into SAS.
The libname statement below creates a SAS library named extern and links the library extern to the directory "C:\temp" on the computer. The data set copy_cd4count.sas7bdat which is stored in the directory "C:\temp", is now in the extern SAS library and can be used immediately in SAS data steps and procedures. Note that once it has been linked to the extern SAS library, it does not need the extension .sas7bdat.
libname extern 'C:\temp' ;
proc means data =extern.copy_cd4cout;
run;
When a library is not specified, SAS automatically uses the temporary library "work."
data dixonmassey;
input Obs chol52 chol62 age cor dchol agelt50;
datalines ;
…
;
run;
[Note: The "dixonmmassey" data set is from Dixon WJ and Massey FJ Jr., Introduction to Statistical Analysis, Fourth Edition, McGraw Hill Book Company, 1983. ]
SAS interprets the first data line as data WORK.dixonmassey;
In the log, the following NOTE will appear:
NOTE: The data set WORK.DIXONMASSEY has 20 observations and 7 variables.
Remember that the work library is only temporary and when SAS is closed all of the datasets in work are deleted.
return to top | previous page | next page
How To Create Permanent Dataset In Sas
Source: https://sphweb.bumc.bu.edu/otlt/mph-modules/bs/sas/sas-basics1/SAS-Basics14.html
Posted by: vangentler63.blogspot.com
0 Response to "How To Create Permanent Dataset In Sas"
Post a Comment