Programming the statistical procedures from SAS

how to convert categorical variables into continuous variables

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 16
Accepted Solution

how to convert categorical variables into continuous variables

In Generalized liner model,  there are totally 120 categorical variables  as predictorsand each of them have 20 levels. I tried to convert these categorical variables into continuous variables so that I can build the model; however, I did not know how to do so.

Who knows? Thanks.


Accepted Solutions
Solution
‎07-06-2017 08:57 AM
SAS Super FREQ
Posts: 3,547

Re: how to convert categorical variables into continuous variables

Obviously, the categories need to be ordinal so that you can order them. Maybe you have levels such as "bad", "ok", "good", and "excellent"? The way that you convert these to numbers will affect your answer. You can recode those levels as 1,2,3,4, or you might decide that "bad" and "excellent" have more extreme values, and so you recode as 0, 2,3,5.

There is some terse discussion of this in the doc for the SCORES statement of the FREQ procedure:

http://support.sas.com/documentation/cdl/en/procstat/63963/HTML/default/viewer.htm#procstat_freq_a00...

For a technical consideration of whether you should do this, along with instructions how, see Analysis of Ordinal Categorical Data by Alan Agresti. You can also try an internet seach using terms such as Ordinal Categories Rank Ridit Scores.

View solution in original post


All Replies
Respected Advisor
Posts: 2,655

how to convert categorical variables into continuous variables

Without seeing the code you are using to do the analysis, I hesitate to offer a solution.  However, it could be as simple as not including the predictors in the class statement, provided the variables have a natural ordering.  Also, why do you have to convert to build the model?  Both PROC GLIMMIX and PROC GENMOD can fit categorical models.  If you are thinking of some sort of stepwise model building, please look at http://communities.sas.com/thread/30130?tstart=0, where some strong caveats are presented.

Good luck.

Solution
‎07-06-2017 08:57 AM
SAS Super FREQ
Posts: 3,547

Re: how to convert categorical variables into continuous variables

Obviously, the categories need to be ordinal so that you can order them. Maybe you have levels such as "bad", "ok", "good", and "excellent"? The way that you convert these to numbers will affect your answer. You can recode those levels as 1,2,3,4, or you might decide that "bad" and "excellent" have more extreme values, and so you recode as 0, 2,3,5.

There is some terse discussion of this in the doc for the SCORES statement of the FREQ procedure:

http://support.sas.com/documentation/cdl/en/procstat/63963/HTML/default/viewer.htm#procstat_freq_a00...

For a technical consideration of whether you should do this, along with instructions how, see Analysis of Ordinal Categorical Data by Alan Agresti. You can also try an internet seach using terms such as Ordinal Categories Rank Ridit Scores.

🔒 This topic is solved and locked.

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

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