BookmarkSubscribeRSS Feed
chelseaxxlutz
Obsidian | Level 7

Hello,

 

Using SAS 9.4, I am trying to score my predicted risk values for results from my proc phreg, but am getting an error and do not know how to continue from here. Basically, I have my estimates from proc phreg, then I want to rank my predicted risk and split it into deciles. Please see below for my code and error messages. Thank you in advance for the help!

 

proc phreg data=riskvalid concordance outest=predicted;

class sex (ref='1') agecat(ref='1') bmicateg(ref='1') diabetes(ref='1') prevap(ref='0') prevmi(ref='0') prevhyp(ref='0') cholcateg(ref='1') smokecateg(ref='1');

AllCause: model timedth*death(0)=riskscore sex agecat bmicateg diabetes prevap prevmi prevhyp cholcateg smokecateg/rl;

output out=outp3 xbeta=xb resmart=mart resdev=dev;

run;

proc print data=predicted;

run;

proc score data=riskvalid out=results score=predicted type=parms predict out=pred;

var riskscore sex agecat bmicateg diabetes prevap prevmi prevhyp cholcateg smokecateg;

run;

 

ERROR: Variable SEX not found.

ERROR: Variable AGECAT not found.

ERROR: Variable BMICATEG not found.

ERROR: Variable DIABETES not found.

ERROR: Variable PREVAP not found.

ERROR: Variable PREVMI not found.

ERROR: Variable PREVHYP not found.

ERROR: Variable CHOLCATEG not found.

ERROR: Variable SMOKECATEG not found.

584 run;

NOTE: The SAS System stopped processing this step because of errors.

WARNING: The data set WORK.RESULTS may be incomplete. When this step was stopped there were 0

observations and 0 variables.

WARNING: Data set WORK.RESULTS was not replaced because this step was stopped.

NOTE: PROCEDURE SCORE used (Total process time):

real time 0.00 seconds

cpu time 0.01 seconds

 

Any reason why all of my variables would disappear? Thank you!

 

Best,

Chelsea

7 REPLIES 7
WarrenKuhfeld
Ammonite | Level 13

Your original variables are not used in the analysis.  Coded variables made from them are.  Run PROC CONTENTS on both data sets and compare them.

chelseaxxlutz
Obsidian | Level 7

Hi Warren,

 

I tried using the variables listed in the proc contents of the new dataset, and now get this error:

 

proc phreg data=riskvalid concordance outest=predicted;

class sex (ref='1') agecat(ref='1') bmicateg(ref='1') diabetes(ref='1') prevap(ref='0') prevmi(ref='0') prevhyp(ref='0') cholcateg(ref='1') smokecateg(ref='1');

AllCause: model timedth*death(0)=riskscore sex agecat bmicateg diabetes prevap prevmi prevhyp cholcateg smokecateg/rl;

output out=outp3 xbeta=xb resmart=mart resdev=dev/* store precitedvalid*/;

run;

 

proc score data=riskvalid out=results score=predicted type=parms predict out=pred;

var riskscore sex2 agecat2 agecat3 agecat4 bmicateg2 bmicateg3 diabetes0 prevhyp1 cholcateg2 cholcateg3 cholcateg4 smokecateg2 smokecateg3;

run;

 

ERROR: In the DATA= data set, cannot find the variable sex2 from the SCORE= data set.

ERROR: In the DATA= data set, cannot find the variable agecat2 from the SCORE= data set.

ERROR: In the DATA= data set, cannot find the variable agecat3 from the SCORE= data set.

ERROR: In the DATA= data set, cannot find the variable agecat4 from the SCORE= data set.

ERROR: In the DATA= data set, cannot find the variable bmicateg2 from the SCORE= data set.

ERROR: In the DATA= data set, cannot find the variable bmicateg3 from the SCORE= data set.

ERROR: In the DATA= data set, cannot find the variable diabetes0 from the SCORE= data set.

ERROR: In the DATA= data set, cannot find the variable prevhyp1 from the SCORE= data set.

ERROR: In the DATA= data set, cannot find the variable cholcateg2 from the SCORE= data set.

ERROR: In the DATA= data set, cannot find the variable cholcateg3 from the SCORE= data set.

ERROR: In the DATA= data set, cannot find the variable cholcateg4 from the SCORE= data set.

ERROR: In the DATA= data set, cannot find the variable smokecateg2 from the SCORE= data set.

ERROR: In the DATA= data set, cannot find the variable smokecateg3 from the SCORE= data set.

 

Thank you!

Reeza
Super User

Please post your full log. 

If you can recode this to work with SASHELP.HEART or provide sample data we can test this before making suggestions.....

chelseaxxlutz
Obsidian | Level 7

Hi Reeza,

 

I actually fixed the error posted below, as I misspelled "predicted" in one of the lines. However, now I am receiving this. You can see in the last chunk of error messages, only class variables are accepted. I have tried looking up syntax to see what other statement I need for it to accept "riskscore" but have been unsuccessful. Many thanks!

 

640 proc phreg data=riskvalid concordance /*outest=predicted*/;

641 class sex (ref='1') agecat(ref='1') bmicateg(ref='1') diabetes(ref='1') prevap(ref='0')

641! prevmi(ref='0') prevhyp(ref='0') cholcateg(ref='1') smokecateg(ref='1');

642 model timedth*death(0)=riskscore sex agecat bmicateg diabetes prevap prevmi prevhyp

642! cholcateg smokecateg/rl;

643 /*output out=outp3 xbeta=xb resmart=mart resdev=dev*/ store precitedvalid;

644 run;

NOTE: The CLASS variable prevap has only one level.

NOTE: The CLASS variable prevmi has only one level.

NOTE: 45 observations were deleted due either to missing or invalid values for the time, censoring,

frequency or explanatory variables or to invalid operations in generating the values for some

of the explanatory variables.

NOTE: Convergence criterion (GCONV=1E-8) satisfied.

NOTE: The PHREG procedure generated the model item store WORK.PRECITEDVALID.

NOTE: PROCEDURE PHREG used (Total process time):

real time 0.15 seconds

cpu time 0.29 seconds

 

645 proc phreg data=riskvalid concordance /*outest=predicted*/;

646 class sex (ref='1') agecat(ref='1') bmicateg(ref='1') diabetes(ref='1') prevap(ref='0')

646! prevmi(ref='0') prevhyp(ref='0') cholcateg(ref='1') smokecateg(ref='1');

647 model timedth*death(0)=riskscore sex agecat bmicateg diabetes prevap prevmi prevhyp

647! cholcateg smokecateg/rl;

648 /*output out=outp3 xbeta=xb resmart=mart resdev=dev*/ store predictedvalid;

649 run;

NOTE: The CLASS variable prevap has only one level.

NOTE: The CLASS variable prevmi has only one level.

NOTE: 45 observations were deleted due either to missing or invalid values for the time, censoring,

frequency or explanatory variables or to invalid operations in generating the values for some

of the explanatory variables.

NOTE: Convergence criterion (GCONV=1E-8) satisfied.

NOTE: The PHREG procedure generated the model item store WORK.PREDICTEDVALID.

NOTE: PROCEDURE PHREG used (Total process time):

real time 0.15 seconds

cpu time 0.10 seconds

 

650 proc plm restore=predictedvalid;

651 show cov Parms;

652 lsmeans riskscore sex agecat bmicateg diabetes prevap prevmi prevhyp cholcateg smokecateg /

652! diff;

ERROR: Only CLASS variables allowed in this effect.

NOTE: PROCEDURE PLM used (Total process time):

real time 0.00 seconds

cpu time 0.00 seconds

NOTE: The SAS System stopped processing this step because of errors.

653 score data=NewData out=ScoreResults;

654 run;

Reeza
Super User

Do you need the LSMEANS? From your description, I assume you'd use a SCORE statement instead?

 

Examples of how to score are here:

https://blogs.sas.com/content/iml/2014/02/19/scoring-a-regression-model-in-sas.html

chelseaxxlutz
Obsidian | Level 7

Hi Reeza,

 

I tried that with the below code and received this new error:

 

proc phreg data=riskvalid concordance /*outest=predicted*/;

class sex (ref='1') agecat(ref='1') bmicateg(ref='1') diabetes(ref='1') prevap(ref='0') prevmi(ref='0') prevhyp(ref='0') cholcateg(ref='1') smokecateg(ref='1');

AllCause: model timedth*death(0)=riskscore sex agecat bmicateg diabetes prevap prevmi prevhyp cholcateg smokecateg/rl;

/*output out=outp3 xbeta=xb resmart=mart resdev=dev*/ store precitedvalid;

run;

 

ERROR: The file WORK.PREDICTEDVALID does not exist or it is not a valid item store.

 

Thank you very much!

 

SAS Innovate 2025: Call for Content

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!

Submit your idea!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 7 replies
  • 2560 views
  • 0 likes
  • 3 in conversation