Hi there, I am a beginner in SAS. I have attached an excel for your assistance..
please can anyone tell me the code to :
1. Calculate the weight age of all the numeric columns in a data set (sum/ total sample size) and accordingly filter out those columns/ variables which have a weight age of less than 2%. The filtered output is stored in a new data set. (step 1 tab in the excel file attached)
2. As per the step 2 in the excel file attached, I now want to use proc logistic and get the desired output as given in the step 2 tab of the excel.
It would be really kind of you to provide the complete code as I am new to SAS.
How Many thanks for your co operation and time !!
Not sure that this makes sense from a statistical analysis point of view.
To find the variables with at least 2% positive response rate for binary variables you can just take the MEAN.
You do not need to generate a new version of the source data, just the list of variables to include in your analysis.
Here is one way to get the list of variables with at least 2% positive responses into the macro variable VARLIST.
proc summary data=HAVE ;
var _numeric_;
output out=means (drop=_type_ _freq_);
run;
proc transpose data=means out=vertical;
id _stat_;
run;
proc sql noprint ;
select _name_ into :varlist separated by ' '
from vertical
where mean > 0.02
;
quit;
%put varlist=&varlist;
Not sure that this makes sense from a statistical analysis point of view.
To find the variables with at least 2% positive response rate for binary variables you can just take the MEAN.
You do not need to generate a new version of the source data, just the list of variables to include in your analysis.
Here is one way to get the list of variables with at least 2% positive responses into the macro variable VARLIST.
proc summary data=HAVE ;
var _numeric_;
output out=means (drop=_type_ _freq_);
run;
proc transpose data=means out=vertical;
id _stat_;
run;
proc sql noprint ;
select _name_ into :varlist separated by ' '
from vertical
where mean > 0.02
;
quit;
%put varlist=&varlist;
Dear Tom,
Thanks for your assistance. I will try this code and update you soon with what I intend to do here
Kind regards
Dear Tom,
I successfully ran your code
I, then tried the point no. 2 as mentioned in the initial question - "to use proc logistic and get the desired output as given in the 'step 2' tab of the excel".
proc summary data=Experiment ;
var _numeric_;
output out=means (drop=_type_ _freq_);
run;
proc transpose data=means out=vertical;
id _Stat_;
run;
proc sql ;
select _name_ into :varlist separated by ' '
from vertical
where mean > 0.02
;
quit;
%put varlist=&varlist;
PROC LOGISTIC DATA=?? descending;
MODEL detractor = ?? ;
RUN;
I am trying to figure out, how do I assign only those independent variables which have a mean value greater than 0.02 and more importantly get the desired output as shown in the step 2 tab of the excel attached. I believe there would some selection (forward backward etc)..
Thank you so much for taking out time to read all this
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 25. Read more here about why you should contribute and what is in it for you!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.