Hi, I am working with a dataset that already has existing format names added to it. I would like to know if there is a possibility of renaming the format names.
For example, currently the format name is XX_SEG and I would like the format name to only be SEG.
I found this information online, but I am not quite sure if it is what I am looking for: http://support.sas.com/kb/22/189.html
You can rename a format, but you'll need to assign the new name to the data set as well. It will not update automatically to know the format has changed.
proc catalog catalog=Formats;
change age_fmt = new_age_fmt (et=format);
run;quit;
/*This program demonstrates how a built in SAS format works. It uses the WORDS format to display the age as thirteen rather than 13. It also creates two additional variables, one is numeric and formatted, the second is a character variable with the same value Author: F.Khurshed Date: 2018-03-23 */ proc format; value age_fmt low - 13 = 'Pre Teen' 13 - 16 = 'Teen' 16 - high = 'Adult'; run; *Create a sample data set; data class; set sashelp.class; *create a variable identical to age, but formatted; age_numeric_format = age; format age_numeric_format age_fmt.; *Recode variable into character rather than use a format; age_character = put(age, words.); run; title 'Demo of Formats'; proc print data=class; run; title 'Check formats and type for AGE variables'; proc contents data=class;run; title; proc catalog catalog=Formats; change age_fmt = new_age_fmt (et=format); run;quit; title 'Check formats and type for AGE variables'; proc contents data=class;run; title;
You can rename a format, but you'll need to assign the new name to the data set as well. It will not update automatically to know the format has changed.
proc catalog catalog=Formats;
change age_fmt = new_age_fmt (et=format);
run;quit;
/*This program demonstrates how a built in SAS format works. It uses the WORDS format to display the age as thirteen rather than 13. It also creates two additional variables, one is numeric and formatted, the second is a character variable with the same value Author: F.Khurshed Date: 2018-03-23 */ proc format; value age_fmt low - 13 = 'Pre Teen' 13 - 16 = 'Teen' 16 - high = 'Adult'; run; *Create a sample data set; data class; set sashelp.class; *create a variable identical to age, but formatted; age_numeric_format = age; format age_numeric_format age_fmt.; *Recode variable into character rather than use a format; age_character = put(age, words.); run; title 'Demo of Formats'; proc print data=class; run; title 'Check formats and type for AGE variables'; proc contents data=class;run; title; proc catalog catalog=Formats; change age_fmt = new_age_fmt (et=format); run;quit; title 'Check formats and type for AGE variables'; proc contents data=class;run; title;
Hi Reeza,
Thank you so much for your help!
Just to clarify, I would use the proc catalog statement first and then assign the new name to the dataset? How exactly would I assign the new format name.
In addition, in the proc catalog statement, is "Formats" my original dataset?
Thank you!
You need to know the catalog name of where you're storing your formats. That part is up to you.
data output;
set input;
format var new_age_format.; *apply new format;
run;
You could also use PROC DATASETS to modify the format, if the data set is big that's a good idea.
Hi Reeza,
Thank you so much for your help, it worked!
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.
Ready to level-up your skills? Choose your own adventure.