BookmarkSubscribeRSS Feed
Xiaoningdemao
Quartz | Level 8

Hello everyone,

 

Here I have a question about how to perform mathematic computation across datasets.

 

Say I have a dataset coefficient like this:

variable       coef

age             15

gender         3

hight            6

 

and another dataset student which have variables age, gender, hight, and others (all numerical):

ID         age    gender    hight     grade  weight  

1015      5           0          146        10         37

.........

 

 

I want to compute a score of each row in dataset "student " by using the value of variables in student  time the corresponding coef in data coefficient and then sum up, i.e. :  age*15+gender*3+hight*6.

 

Can someone help me realize this?

 

Thank you very much!!!

 

Best wishes.

 

 

 

6 REPLIES 6
Reeza
Super User

Where do the coefficients come from?

Can you use PROC SCORE to implement this somehow?

Xiaoningdemao
Quartz | Level 8

Hi Reeza,

 

Yes, it is the coefficents from SAS output.

I tried proc score as you suggestted, but i have categorical variable, say rank, which has 5 levels, when i score it, the coefficents become rank1 rank2 rank3 rank4 rank5...

How to resolve this problem?

 

Thank you very much!!!

Reeza
Super User

PROC SCORE will handle the categorical variables as long as the data used for scoring is identical, in format, to the input data. 

Xiaoningdemao
Quartz | Level 8

Dear Reeza,

 

This is the code I'm using,

proc logistic data=modeldata descending outest=modelname ;

model outcome= &continue_vars &class_vars;

output out=modeldata PREDICTED=prob;

run;

 

proc score data=dataname score=modelname out=dataname type=parms;

var &continue_vars &class_vars;

run;

 

&class_vars contains categorical variables, in the PROC SCORE, it just keep giveing me error messages, saying those variables (&class_vars) not found:

 

Thank you!!!

 

Reeza
Super User

You need to score a logistic model using proc logistic not proc score but since this requires a stored model, not the parameter data  set that won't work.  

 

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 6 replies
  • 834 views
  • 0 likes
  • 2 in conversation