I run a sas program and want to save the final table in sas format. So I can use the sas file directly in the future. How to save this table in sas format?
If I cannot save it in sas format, I can export this table into a CSV file. But I encounter a problem in the CSV file. For example,
SAS Fomat CSV
CUSIP CUSIP
000888999 888999
00088E104 8.8E+105
.... ....
Then I import the CSV file into sas and cannot the result in the original SAS format. How to solve this problem? Thanks
If your final table is a SAS dataset you could create a permanent SAS-library (in case you are using the Enterprise Guide, there is an export button).
If your final table is the output of a procedure you could use the Output Delivery System-Output to get the procedure result and store it (in a library).
I use sas 9.3 Not the Enterprise version. How to export the SAS dataset by creating a permanent SAS-library?
The enterprise version only displays the first 50 tables but the final table is beyond 50th.
You can use either in Enterprise Guide: Click on your data file > Enterprise menu: "File" > "Export" > "Export <Filename>" > choose a directory and make sure that the "Files of type" is "Sas data file ..".
Or use code. This example "copies" the work file "A" to a folder:
* this is a work-file (non-permanent);
Data Have;
Do i=1 To 10 ; Output; End;
Run;
Libname MyLib "C:\Users\USERNAME\Desktop\SAS folder"; * check the path and make sure the folder exists - create manually :smileyalert: if necessary;
Data Have; * "copy" the work file to the library;
Set MyLib.Have;
Run;
.. hope it helps 🙂
I'd rather do
Data MyLib.Have;
Set Have;
Run;
You're right, that was silly.
Data MyLib.Have;
Set Have;
Run;
it is.
Look for the step that produces your final dataset in the code and then alter the data .....; statement or the out= (if it is some other procedure) so that the dataset is created in a permanent library instead of work.
And just related to the appearance: Be very careful opening CSV files in Excel (and likely some other spreadsheets) as it tries to be "helpful" and treats what you thought was a character 0008899 as a numeric. If you save the file from Excel will change the actual value.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.