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.
Are you kidding? Three requests, all without any example data or the smallest effort shown, that you tried anything.
I am not kidding Andreas. I am new to SAS macros.......that's why asking...
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.
/* 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 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.