Format race variable

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 13
Accepted Solution

Format race variable

I have a variable race with 5 sub groups: white, black, asian, unknown, and other. How do I format this variable into 3 sub groups: Black, White, and Other.?


Accepted Solutions
Solution
‎10-10-2015 01:23 PM
Respected Advisor
Posts: 4,609

Re: Format race variable

[ Edited ]

Define a character format and apply it to your variable, when needed

 

proc format;
value $ raceBW
"white","White","WHITE" = "White"
"black","Black","BLACK" = "Black"
OTHER = "Other";
run; data _null_; length race $12; do race = "white", "black", "asian", "unknown", "other", "whatever"; put race "becomes -> " race :$raceBW.; end; run;
PG

View solution in original post


All Replies
Respected Advisor
Posts: 3,837

Re: Format race variable

[ Edited ]
Solution
‎10-10-2015 01:23 PM
Respected Advisor
Posts: 4,609

Re: Format race variable

[ Edited ]

Define a character format and apply it to your variable, when needed

 

proc format;
value $ raceBW
"white","White","WHITE" = "White"
"black","Black","BLACK" = "Black"
OTHER = "Other";
run; data _null_; length race $12; do race = "white", "black", "asian", "unknown", "other", "whatever"; put race "becomes -> " race :$raceBW.; end; run;
PG
Occasional Contributor
Posts: 13

Re: Format race variable

PGStats
Thank you for help. You solve my problem. Awesome!!
proc format;
value $ raceBW
"white","White","WHITE" = "White"
"black","Black","BLACK" = "Black"
OTHER = "Other";run;
☑ This topic is SOLVED.

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

Discussion stats
  • 3 replies
  • 449 views
  • 0 likes
  • 3 in conversation