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

Hi

 

I am running the below code and generate sum and mean for different variables.

 

 

PROC MEANS DATA=calcu1 mean SUM MAXDEC=2 ;
var Absolute_error Absolute_errorpercentage Square_errors correctsign;
RUN;

Now I want to create another variable in the same table. New variable name is RSME. And I want to square root the mean of absolute_Error value and store into RSME?

 

Please suggesr

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

I don't think PROC MEANS is the tool here. Try PROC SQL and do something like this

 

proc sql;
   create table calcu2 as
   select *, 
          sqrt(mean(absolute_Error)) as RSME
   from calcu1;
quit;

View solution in original post

4 REPLIES 4
PeterClemmensen
Tourmaline | Level 20

I don't think PROC MEANS is the tool here. Try PROC SQL and do something like this

 

proc sql;
   create table calcu2 as
   select *, 
          sqrt(mean(absolute_Error)) as RSME
   from calcu1;
quit;
Reeza
Super User

RMSE doesn't appear to be a calculated statistic within PROC MEANS, but CSS may help you get there along with the N. 

 

https://documentation.sas.com/?docsetId=proc&docsetTarget=n1qnc9bddfvhzqn105kqitnf29cp.htm&docsetVer...

 

You cannot calculate a new variable within PROC MEANS. You'll have to either do it manually or capture the output and calculate it later.


@sdhilip wrote:

Hi

 

I am running the below code and generate sum and mean for different variables.

 

 

PROC MEANS DATA=calcu1 mean SUM MAXDEC=2 ;
var Absolute_error Absolute_errorpercentage Square_errors correctsign;
RUN;

Now I want to create another variable in the same table. New variable name is RSME. And I want to square root the mean of absolute_Error value and store into RSME?

 

Please suggesr


 

sdhilip
Quartz | Level 8

Thanks @Reeza@PeterClemmensen

 

Now I calculated Sum Square Error, Sum Absolute Error, Sum Absolute percentage error by using 

proc print data=calcu1; 
       var nyse forecast std Absolute_errors Square_errors 
       Absolute_error_percentage correct_sign_perc; 
       sum Absolute_errors Square_errors Absolute_error_percentage correct_sign_perc;
run;

 

output

 

Capture.JPG

 

Now I would like to calculate the following

 

My observation is 22

 

1)  Mean Square error  (Sum Square error / 22)

2)  Mean Absolute error (Sum Absolute error / 22)

3)  Mean Absolute percentage error (Sum Absolute Percentage error /22)

4) % correct sign _prediction - I just need to print the above 13 value in the table into 13 %.

5) Finally, I want to calculate = RMSE (Sq.rt(mean square error)

 

 

The above items need to be stored in the same table or a different table:

 

And I would like to have the following

 

Untitled.png

 

I have gone through all the posts but unable to find the solution. Could you please help? Either I need to have the details in a different table or in the same table

Reeza
Super User
Run PROC MEANS again on the outputted data if that's what you need, you're just requesting different statistics.