DATA Step, Macro, Functions and more

how to insert an other value in an existing string proc format

Accepted Solution Solved
Reply
New Contributor
Posts: 3
Accepted Solution

how to insert an other value in an existing string proc format

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?


Accepted Solutions
Solution
2 weeks ago
Super User
Posts: 6,921

Re: how to insert an other value in an existing string proc format

Posted in reply to john_sanzone

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.

View solution in original post


All Replies
Super User
Posts: 13,913

Re: how to insert an other value in an existing string proc format

Posted in reply to john_sanzone

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?

Solution
2 weeks ago
Super User
Posts: 6,921

Re: how to insert an other value in an existing string proc format

Posted in reply to john_sanzone

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.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 124 views
  • 0 likes
  • 3 in conversation