- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
From a SAS program, I've generated a format file (formats.sas7bcat) that applies values to a given SAS dataset. For the dataset, in a given column, the values will be reformatted. For example, for a column 'PAYMENT' with given values of {'1', '2', '3', '4'} the values will be reformatted to something like {'credit card', 'cash', 'check', 'other'}.
To export the translated dataset I've done:
proc export
data = temp_lib.data1
outfile = /*file location & filename.csv*/
label
dbms = CSV
replace;
putnames = yes;
run;
I have 100+ formats. Instead of exporting the translated datasets, how would I go about exporting only the formats to a csv file? Something like:
variable, value, label
PAYMENT, 1, 1='credit card'
PAYMENT, 2, 2='cash'
PAYMENT, 3, 3='check'
PAYMENT, 4, 4='other'
other variable, other value, other label...
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Pipe them to a data set? That same data set can then be imported back in
*pipe data to a file;
proc format cntlout = myFormats;
run;
proc export data=myFormats outfile='/folders/myfolders/myFOrmats.csv' dbms=csv replace;run;
*to recreate the formats from the data set;
proc format cntlin = myformats;
run;
@Peter_I_SAS00 wrote:
From a SAS program, I've generated a format file (formats.sas7bcat) that applies values to a given SAS dataset. For the dataset, in a given column, the values will be reformatted. For example, for a column 'PAYMENT' with given values of {'1', '2', '3', '4'} the values will be reformatted to something like {'credit card', 'cash', 'check', 'other'}.
To export the translated dataset I've done:
proc export
data = temp_lib.data1
outfile = /*file location & filename.csv*/
label
dbms = CSV
replace;
putnames = yes;
run;
I have 100+ formats. Instead of exporting the translated datasets, how would I go about exporting only the formats to a csv file? Something like:
variable, value, label
PAYMENT, 1, 1='credit card'
PAYMENT, 2, 2='cash'
PAYMENT, 3, 3='check'
PAYMENT, 4, 4='other'
other variable, other value, other label...
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Pipe them to a data set? That same data set can then be imported back in
*pipe data to a file;
proc format cntlout = myFormats;
run;
proc export data=myFormats outfile='/folders/myfolders/myFOrmats.csv' dbms=csv replace;run;
*to recreate the formats from the data set;
proc format cntlin = myformats;
run;
@Peter_I_SAS00 wrote:
From a SAS program, I've generated a format file (formats.sas7bcat) that applies values to a given SAS dataset. For the dataset, in a given column, the values will be reformatted. For example, for a column 'PAYMENT' with given values of {'1', '2', '3', '4'} the values will be reformatted to something like {'credit card', 'cash', 'check', 'other'}.
To export the translated dataset I've done:
proc export
data = temp_lib.data1
outfile = /*file location & filename.csv*/
label
dbms = CSV
replace;
putnames = yes;
run;
I have 100+ formats. Instead of exporting the translated datasets, how would I go about exporting only the formats to a csv file? Something like:
variable, value, label
PAYMENT, 1, 1='credit card'
PAYMENT, 2, 2='cash'
PAYMENT, 3, 3='check'
PAYMENT, 4, 4='other'
other variable, other value, other label...
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You may want to consider learning about the proc fromat CNTLOUT option to create a data set from the definitions. The output data set would have the format name, the start and end values(for ranges) and the value label plus some other stuff like whether it is a character value, multilabel, informat (invalue) or format, has an "other" range defined and such.
Your target CSV is also missing something unless you have 1) absolutely no formats with ranges of values (missing one end of the range) or 2) no formats for missing values.