DATA Step, Macro, Functions and more

Calculate variance and use values for further calculations

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 8
Accepted Solution

Calculate variance and use values for further calculations

Hello,

new day and I have new SAS beginners problem. I want to calculate the variance for two parameters in my data set and in the next step I want to do some calculations with the just calculated variances. For that I tried to write a macro because I want to apply that method on some more data sets:

%MACRO calculateICC(data, name);
   PROC UNIVARIATE DATA = &data;
   VAR a;
   VAR e;
   OUTPUT out = var VAR=vara VAR=vare;
   data ic&name;
   set var;
   ic = vara/(vara + vare);
   output out = ic;
   run;
%MEND;

I think the first part is wokring alright. But the second part is messed up.


Accepted Solutions
Solution
‎08-31-2017 04:20 PM
SAS Super FREQ
Posts: 3,755

Re: Calculate variance and use values for further calculations

The DATA step does not have an OUTPUT statement. Delete that statement, as indicated below

data ic&name;
   set var;
   ic = vara/(vara + vare);
/*   output out = ic; DELETE */
   run;

 

View solution in original post


All Replies
Trusted Advisor
Posts: 1,932

Re: Calculate variance and use values for further calculations

[ Edited ]

mrer wrote:

Hello,

new day and I have new SAS beginners problem. I want to calculate the variance for two parameters in my data set and in the next step I want to do some calculations with the just calculated variances. For that I tried to write a macro because I want to apply that method on some more data sets:

%MACRO calculateICC(data, name);
   PROC UNIVARIATE DATA = &data;
   VAR a;
   VAR e;
   OUTPUT out = var VAR=vara VAR=vare;
   data ic&name;
   set var;
   ic = vara/(vara + vare);
   output out = ic;
   run;
%MEND;

I think the first part is wokring alright. But the second part is messed up.


We have no idea what you mean by "first part". We have no idea what you mean by "second part". We have no idea what "messed up" means.

 

Please be extremely specific.

 

Please show us sample data.

 

Please show us the SASLOG or output data set and explain clearly and in detail what is "messed up".

Solution
‎08-31-2017 04:20 PM
SAS Super FREQ
Posts: 3,755

Re: Calculate variance and use values for further calculations

The DATA step does not have an OUTPUT statement. Delete that statement, as indicated below

data ic&name;
   set var;
   ic = vara/(vara + vare);
/*   output out = ic; DELETE */
   run;

 

Occasional Contributor
Posts: 8

Re: Calculate variance and use values for further calculations

Thanks! It is working now.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 114 views
  • 2 likes
  • 3 in conversation