Help using Base SAS procedures

Weight age of each numeric column/ variable and then filter out

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 5
Accepted Solution

Weight age of each numeric column/ variable and then filter out

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 !!


Accepted Solutions
Solution
‎12-17-2012 09:50 AM
Super User
Super User
Posts: 7,060

Re: Weight age of each numeric column/ variable and then filter out

Posted in reply to gaurav21s

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;

View solution in original post


All Replies
Solution
‎12-17-2012 09:50 AM
Super User
Super User
Posts: 7,060

Re: Weight age of each numeric column/ variable and then filter out

Posted in reply to gaurav21s

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;

Occasional Contributor
Posts: 5

Re: Weight age of each numeric column/ variable and then filter out

Dear Tom,

Thanks for your assistance. I will try this code and update you soon with what I intend to do here Smiley Happy

Kind regards

Occasional Contributor
Posts: 5

Re: Weight age of each numeric column/ variable and then filter out

Dear Tom,

I successfully ran your code Smiley Happy

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 Smiley Happy

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 334 views
  • 1 like
  • 2 in conversation