BookmarkSubscribeRSS Feed
robbie94
Calcite | Level 5

I am working with a large dataset that contains a lot of confusing codes. I have formatted these codes as simple words to make it easier for individuals who may analyze the data later on to understand. When I create these formats and export them, I notice in the exported SAS datafile that none of the formats are preserved. I have been using the following code to export my data:

 

libname out '\C:\data\etc';

 

proc datasets library=work nodetails nolist;
copy in=work out=out;
select mydata;
run;quit;

 

Is there anyway that I can export as a SAS data set and preserve my formats? I have seen countless ways to do this with excel data using the proc export procedure, but I can't use proc export to create .sas7bdat files. 

3 REPLIES 3
ChrisNZ
Tourmaline | Level 20

Your explanation is probably incomplete.
Format assignments are copied along when a data set is copied.

data kk; 
  format d date.;
run;
proc datasets noprint; 
  copy in=work out=data_rw;
  select kk;
run;
proc contents data=data_rw.kk; 
run;
 

SAS Output

The CONTENTS Procedure
Data Set Name DATA_RW.KK Observations 1
Member Type DATA Variables 1
Engine V9 Indexes 0
Created 31/07/2018 11:50:54 Observation Length 8
Last Modified 31/07/2018 11:50:54 Deleted Observations 0
Protection   Compressed NO
Data Set Type   Sorted NO
Label      
Data Representation WINDOWS_64    
Encoding wlatin1 Western (Windows)    



Alphabetic List of Variables and Attributes
# Variable Type Len Format
1 d Num 8 DATE.


Please give more details.

Tom
Super User Tom
Super User

Send the format definitions along with the dataset.

Preferable as source code for the PROC FORMAT step to create them.

If not that then as a dataset that can be used to generate them using PROC FORMAT with the CNTLIN= option.

Or if you have to as an exported transport file made with PROC CPORT.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 3 replies
  • 827 views
  • 0 likes
  • 4 in conversation