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

what i meant is that the (%put &=indplist_indp1) contains all independant variables (indp1 .. indp16) regardless of their P-value. I thought the list contains only significant variables (if the P-value < 0.05).

samnan
Quartz | Level 8

Ithink that because of the follwoing:

first let explain here what i got in the list in terms of the (parameter):

 

Intercept

exp

indp1

Dispersion

 

usualy the (Intercept) or the (exp) P-value turns to be significant (p-value < 0.05), so it will be included to the list even if the (indp1) insignificant.

 

 

FreelanceReinh
Jade | Level 19

How can Intercept etc. and non-significant variables be included, given the WHERE clause

 where upcase(parameter) not in ("INTERCEPT", "EXP", "DISPERSION") & .<ProbChiSq<0.05;

in the PROC SQL code?

 

I had tested my code successfully using a subset of SASHELP.CARS as dataset HAVE. Here is a short section from the log:

NOTE: Algorithm converged.
NOTE: The negative binomial dispersion parameter was estimated by maximum likelihood.
NOTE: PROCEDURE GENMOD used (Total process time):
      real time           0.02 seconds
      cpu time            0.01 seconds


4   + ods output close;
NOTE: The data set WORK.EST_INVOICE has 8 observations and 10 variables.
5   + proc sql noprint;
5   +                   select parameter into :indplist_invoice separated by " " from est_invoice where upcase(parameter) not in
("INTERCEPT", "HORSEPOWER", "DISPERSION") & .<ProbChiSq<0.05;
5   +
 quit;
NOTE: PROCEDURE SQL used (Total process time):

A comparison of the above log excerpt with a corresponding section of your SAS log (one such section per dependent variable) will be a promising first step towards finding the issue at your end.

 

Of course, the names "INVOICE" and "HORSEPOWER" are data-specific. The dataset WORK.EST_yourvariablename will show what the PROC SQL step should have written into the pertinent macro variable INDPLIST_yourvariablename.

samnan
Quartz | Level 8

Dear @FreelanceReinh i have tried many times but could not got it; Please find my sample below:

 

 

data have;
infile cards dlm=" ";
input res trans commn commr busn totacc facc fsacc exp;
cards;
0.5106 0.00592 0.00204 0.04674 0.01549 1561 8 45 14.6401
0.54689 0.00368 0.00104 0.01984 0.00878 1293 6 50 14.5009
0.55426 0.00755 0.00368 0.01085 0.0197 1283 6 27 13.7799
0.78301 0.00229 0.00246 0.03242 0.02246 1399 3 25 13.9239
0.52035 0.00555 0.00813 0.00985 0.0148 835 3 24 13.8535
0.52406 0.00045 0.00179 0.01541 0.00757 784 5 15 14.4113
0.54079 0.01462 0.05013 0.01628 0.02279 936 4 13 14.0026
0.0878 0.00312 0.00011 0.00942 0.0025 1034 5 16 14.1336
0.04896 0.00157 0.04674 0.11843 0.0066 1179 8 25 13.9206
0.41158 0.00399 0.00734 0.25723 0.02834 1893 2 31 13.7067
0.62409 0.00807 0.00253 0.03514 0.00633 1699 7 49 13.821
0.34779 0.0289 0.05937 0.04541 0.02666 1900 9 39 14.9494
0.57421 0.00915 0.00181 0.03558 0.00675 1402 3 42 13.9342
0.68064 0.00395 0.0007 0.08047 0.02416 376 0 5 12.6189
0.38445 0.01718 0.00134 0.05237 0.0705 1623 11 42 14.7249
0.71162 0.00409 0.00075 0.02756 0.0264 1433 2 14 14.0926
0.51897 0.00997 0.00074 0.04778 0.03209 5088 11 71 14.894
0.63653 0.00411 0.00374 0.0487 0.0202 2044 7 51 14.6865
0.31564 0.00522 0.00018 0.01399 0.04705 1005 3 20 13.9002
0.35732 0.00522 0.00208 0.04063 0.02346 5741 34 157 15.3313
0.75071 0.01419 0.00551 0.02774 0.01832 980 4 25 13.9193
0.30134 0 0.00008 0.00945 0.00451 671 7 27 14.004
0.24283 0.00123 0.01685 0.00348 0.00336 564 2 10 14.074
0.46881 0.00231 0.00829 0.01293 0.03569 700 1 5 13.7692
0.03949 0.01613 0 0.00055 0.00081 407 1 6 13.2234
0.04287 0.00561 0.04142 0.01772 0.01949 4436 34 99 15.0589
0.32452 0.01828 0.00561 0.08055 0.01413 9017 40 162 15.1009
0.01545 0.00422 0.00205 0.00982 0.03275 2866 39 114 15.7243
0.05259 0.00144 0.08136 0.00561 0.01251 227 1 5 13.9364
0.0216 0.00012 0.00009 0.02055 0.012 2757 11 61 14.2239
0.01964 0.00341 0.00691 0.00493 0.00128 41 0 0 14.2912
0.02977 0.00424 0.01542 0.00407 0.00895 1440 10 35 14.6687
0.49944 0.01248 0.01842 0.01607 0.00833 332 1 4 11.7664
0.57083 0.0105 0.00156 0.12008 0.0259 759 3 13 13.136
0.00176 0.0002 0.01181 0.00386 0.00292 1784 43 126 15.3832
0.01671 0.00037 0.00009 0.00096 0.00116 234 1 6 11.4916
0.02278 0.00003 0.00231 0.0088 0.00024 3272 48 142 14.6535
0.07297 0 0.01172 0 0 62 0 1 9.2823
0.44657 0.06945 0.02416 0.05744 0.12574 1536 3 22 14.0376
0.00054 0 0 0 0.00008 655 14 39 12.7758
0.69536 0.01753 0.00429 0.03601 0.01435 1934 5 37 14.3894
0.49895 0.00396 0 0.26858 0.01808 354 4 14 12.1618
0.02764 0.00178 0.04852 0.01417 0.02677 5776 30 134 15.0845
0.00177 0.0002 0.00037 0.00006 0.00003 126 2 2 11.8863
0.45239 0.01005 0.00076 0.00014 0.01328 1246 4 31 14.4243
0.13396 0.00224 0.01808 0.0079 0.00452 5140 45 240 15.2573
0 0.0708 0 0 0 1272 9 45 13.0868
0.55166 0.01672 0.00734 0.04716 0.00758 2015 12 61 14.5673
0.49025 0.01888 0.01895 0.04154 0.07337 1777 5 18 14.0023
0.10641 0.00109 0.00371 0.03058 0.00735 3680 17 111 15.4036
;run;

data _null_;
array dep totacc facc fsacc;
array indp res trans commn commr busn;
do i=1 to dim(dep);
call execute('ods output ParameterEstimates(persist=proc)=est_' || vname(dep[i]) ||';');
do j=1 to dim(indp);
call execute( 'proc genmod data=have;'
|| 'model ' || vname(dep[i]) || ' = exp ' || vname(indp[j]) || ' /d=nb; run;');
end;
call execute('ods output close;');
call execute('proc sql noprint; select parameter into :indplist_' || vname(dep[i])
|| ' separated by " " from est_' || vname(dep[i])
|| ' where upcase(parameter) not in ("INTERCEPT", "EXP", "DISPERSION") & .<ProbChiSq<0.05; quit;');
end;
run;

%put &=indplist_totacc ;
%put &=indplist_facc ;
%put &=indplist_fsacc;

FreelanceReinh
Jade | Level 19

Hi @samnan,

 

Thank you for posting this realistic example. Good news: I've run your code and found that, as far as I see, all results are correct and as expected. The only WARNING message is the one I announced already in this earlier post: There are no significant predictors for TOTACC among the five candidate variables, hence macro variable INDPLIST_TOTACC is not created and the %PUT statement is not applicable. (We could create it as an empty macro variable if needed.)

 

The other two macro variables contain the lists of (at the 0.05 level) significant independent variables:

INDPLIST_FACC=res busn
INDPLIST_FSACC=busn

These results are in accordance with the datasets EST_TOTACC, EST_FACC and EST_FSACC, which were produced correctly with the expected 20 observations each (=4 obs. for each of the 5 indep. variables).

 

Did you get anything different or what is it that you "could not [get]" although you "have tried many times"?

samnan
Quartz | Level 8

Dear @FreelanceReinh, Yas i just got it eventually where I should check the log not the list for the significant variables, that was my mistake.

 

I need that to see the candidate variables to be included in the model, which your code is enough for me.

however, if you able to manage including all variables and get the significant variables in present of the others will ease a alot of time and become good contribution to the PROC GENMOD from my point view. It just doing similar the option (Selection = forward) in logistic regression.

 

thanks again for your help and cooperation

FreelanceReinh
Jade | Level 19

I don't think there is an easy and indisputable way to select "the" significant predictors from a set of candidate variables. Otherwise, I guess, the developers of PROC GENMOD would have included such a model selection feature.


A general macro to run a series of analyses with the objective of model selection would be fairly complicated.

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 Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 21 replies
  • 2588 views
  • 4 likes
  • 3 in conversation