BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
gaurav21s
Calcite | Level 5

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

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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

3 REPLIES 3
Tom
Super User Tom
Super User

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;

gaurav21s
Calcite | Level 5

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

gaurav21s
Calcite | Level 5

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

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!

What is Bayesian Analysis?

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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