BookmarkSubscribeRSS Feed
almatruk
Calcite | Level 5

Hello, 

 

I am trying to merge the "independent" and "something else" categories into one category. and when I used this code SAS exclude them from the analysis 

here is the code that I use 

"if (POLITIC in (2,4) ) then POLITIC = 'Independent and others';

run;

 

Any suggestions on how to merge those two categories into one?

1 REPLY 1
PaigeMiller
Diamond | Level 26

@almatruk wrote:

Hello, 

 

I am trying to merge the "independent" and "something else" categories into one category. and when I used this code SAS exclude them from the analysis 

here is the code that I use 

"if (POLITIC in (2,4) ) then POLITIC = 'Independent and others';

run;

 

Any suggestions on how to merge those two categories into one?


If variable POLITIC in (2,4) it must be numeric, and you cannot then assign a character string to the variable POLITIC. SAS will not allow this. A better solution (assuming POLITIC is numeric) is the following:

 

proc format;
    value politicf 1='Martian' 2,4='Independent and others' 3='Vulcan' 5='Klingon';
run;

 

and then assign the format POLITICF to your variable in a procedure or in a data step

 

format politic politicf.;

 

--
Paige Miller

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 318 views
  • 0 likes
  • 2 in conversation