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.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1650 views
  • 0 likes
  • 4 in conversation