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.
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
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.
If you use custom formats, you need to supply the defined formats along with your dataset.
How you do that depends on how "far" you want to send your datasets.
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.
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.