BookmarkSubscribeRSS Feed
dsp1
Calcite | Level 5

Hi, I am looking for a macro which needs to do some tasks as mentioned below.

 

It should create dummy variables like we have "Dummies" package in R which will create dummy variables for all categorical variables based on some conditions like in some variables we have categories like more than 20 or 30 etc. and for those type of variables it should skip and drop original variables after creating dummy variables....

 

If anyone have this macro, please share with us...

 

Thanks in advance.

7 REPLIES 7
andreas_lds
Jade | Level 19

I don't know R ... maybe posting what you have and what you want as datasets will make it easier to help you. And also post the code you have already written to solve your problem.

user24feb
Barite | Level 11

In SAS you probably want to use a CLASS-statement. It handles categorical data for proc reg, logistic, glm ..

 

And note that R and SAS are 2 different programming languages. In SAS you can add those statements either to a proc, or you need a data-step to create them yourself.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

And what have you done?  As in your previous posts, this is not a contract work request forum, it is a Q&A forum.  If you have specific questions, then pose the question using descriptive text, with example test data in the form of a datastep, and what you want to see out.  Post code that you have tried, and logs of any errors/warnings.

PaigeMiller
Diamond | Level 26

@dsp1 wrote:

Hi, I am looking for a macro which needs to do some tasks as mentioned below.

 

It should create dummy variables like we have "Dummies" package in R which will create dummy variables for all categorical variables based on some conditions like in some variables we have categories like more than 20 or 30 etc. and for those type of variables it should skip and drop original variables after creating dummy variables....

 

If anyone have this macro, please share with us...

 

Thanks in advance.


Hey @dsp1 you could save yourself a lot of time by just doing searches here in this forum or in Google.

 

Here is a long thread that covers lots of good information about creating dummy variables.

https://communities.sas.com/t5/SAS-Procedures/How-can-i-create-dummy-variables-How-can-i-change-my-c...

--
Paige Miller
Reeza
Super User

Note that SAS will do this automatically in some PROCS via the CLASS statement, otherwise, I find this covers most ways to create dummy variables:

 

https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-dummy-variables-Categorical-Var...

 

There are a multitude of ways to do this. 

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 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to choose a machine learning algorithm

Use this tutorial as a handy guide to weigh the pros and cons of these commonly used machine learning algorithms.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 7 replies
  • 1492 views
  • 0 likes
  • 8 in conversation