BookmarkSubscribeRSS Feed
ZZB
Obsidian | Level 7 ZZB
Obsidian | Level 7

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



7 REPLIES 7
user24feb
Barite | Level 11

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).

ZZB
Obsidian | Level 7 ZZB
Obsidian | Level 7

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.

user24feb
Barite | Level 11

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 🙂

user24feb
Barite | Level 11


You're right, that was silly.

Data MyLib.Have;

  Set Have;

Run;

it is.

Kurt_Bremser
Super User

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.

ballardw
Super User

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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 7 replies
  • 1118 views
  • 0 likes
  • 4 in conversation