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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 1142 views
  • 0 likes
  • 8 in conversation