BookmarkSubscribeRSS Feed
dsp1
Calcite | Level 5

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

 

It should check all missing values in the dataset and then drop the variables with high missing values and at the same time impute those numeric and character missing values based on some conditions like in model development we used to follow something like that.

 

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

 

Thanks in advance.

4 REPLIES 4
andreas_lds
Jade | Level 19

Are you kidding? Three requests, all without any example data or the smallest effort shown, that you tried anything.

dsp1
Calcite | Level 5

I am not kidding Andreas. I am new to SAS macros.......that's why asking...

Astounding
PROC Star

If you are serious about this, here's what you need to do.

 

Write a program that works, but doesn't use macros at all.  It has to handle at least one version of the requirements.  For example, it might handle missing numeric values only.  It would calculate the percentage of missing values for every numeric variable, and identify those that are missing at least 20% of the time.  It would replace numerics that have a missing value rate of less than 20% with the mean value for that variable.

 

Turning that into a macro would then mean adding flexibility ... perhaps the 20% cutoff needs to be a macro parameter that can be adjusted when calling the macro.  Perhaps using the mean to replace missing values could be switched to be the median.  But it is up to you to come up with the non-macro code that accomplishes the task in some form or another.

Ksharp
Super User


/* impute missing values *

data class;
set sashelp.class;
if rand('uniform')<0.4 then call missing(sex);
if rand('uniform')<0.2 then call missing(height);
run;
proc mi data=class seed=1305417 nimpute=1 out=outex4;
class sex ;
fcs nbiter=100 ;
var sex age height weight;
run;

*/

 

 

 

 

 


/* Pick up variable by PROC PLS
* ods output VariableImportancePlot= VariableImportancePlot;
proc pls data=class missing=em * nfact=2 plot=(ParmProfiles VIP) * cv=split details cvtest(seed=12345);
class sex;
model age=weight height sex;
* output out=x predicted=p;
run;
*/

 

 

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
  • 4 replies
  • 827 views
  • 0 likes
  • 4 in conversation