## Format race variable

Solved
Occasional Contributor
Posts: 13

# 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
Posts: 5,528

## 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

All Replies
Posts: 4,736

## Re: Format race variable

[ Edited ]
Solution
‎10-10-2015 01:23 PM
Posts: 5,528

## 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 and locked.