Does any one know how to add an "other" entry to an existing SAS proc format. For example you've already built and stored a format called sex:
proc format;
value $sex
'1' = ‘Female’
'2' = ‘Male’
;
run;
Now instead of re-running the above to include an "other" value can I just insert a new "row" into this that says OTHER=Unknown?
I'm a little too rushed to spell it out in detail, but here's the idea.
Run PROC FORMAT, using the CNTLOUT= option. That gives you a SAS data set holding all the information needed to generate the format in its current form.
Modify the SAS data set, adding an observation that changes two variables:
HLO='O'
Label = 'Other'
Use the modified data set as input to PROC FORMAT, using the CNTLIN= option.
@john_sanzone wrote:
Does any one know how to add an "other" entry to an existing SAS proc format. For example you've already built and stored a format called sex:
proc format;
value $sex
'1' = ‘Female’
'2' = ‘Male’
;
run;
Now instead of re-running the above to include an "other" value can I just insert a new "row" into this that says OTHER=Unknown?
Not if you want the format do display "unknown" .
Run
proc format; value $sex '1' = ‘Female’ '2' = ‘Male’ other='Unknown' ; run;
to modify the format.
There is not much overhead in proc format so rerunning the code shouldn't be much of an issue. Why were you worried about rerunning it?
I'm a little too rushed to spell it out in detail, but here's the idea.
Run PROC FORMAT, using the CNTLOUT= option. That gives you a SAS data set holding all the information needed to generate the format in its current form.
Modify the SAS data set, adding an observation that changes two variables:
HLO='O'
Label = 'Other'
Use the modified data set as input to PROC FORMAT, using the CNTLIN= option.
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.
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.