Help using Base SAS procedures

The variable type of 'AGE.sum'n is invalid in this context

Reply
Frequent Contributor
Posts: 77

The variable type of 'AGE.sum'n is invalid in this context

 

 

Been using the drag and drop to do reporting...wanna try learning coding part, read some guides in google and followed some guides. but i am getting some error.

 

so here is my code:

 

 

proc report Headline nowd data=education003v5rightj OUT=REPORTEDUCATION003 /*(KEEP=Age StartYear)*/
SPLIT='*';

 

title'1st Proc Report';
COLUMN Age StartYear University Yandhi;
DEFINE Age /DISPLAY ORDER 'Years/Wasted in life';
DEFINE StartYear /DISPLAY "Commence Year" WIDTH=10 LEFT;
DEFINE University /DISPLAY /*"Your Uni"*/ WIDTH=5 FLOW '*Note*';
DEFINE Yandhi / COMPUTED 'Yandhi and Nathan' format=7.3;
compute Yandhi;
Yandhi = 0.69*Age.sum;
endcomp
;
/*BREAK AFTER age / SUMMARIZE;*/
run;

 

 

Im getting this error:

The variable type of 'AGE.sum'n is invalid in this context

 

 

and secondly, i read online that the split option will split if i have a * but so far it doesnt have any effect on me...am i doing something wrong?

Super User
Posts: 7,830

Re: The variable type of 'AGE.sum'n is invalid in this context

Posted in reply to imdickson

Do you have a column named 'age.sum'n in your dataset? I guess not. Did you mean to simply use age instead in your calculation?

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Frequent Contributor
Posts: 77

Re: The variable type of 'AGE.sum'n is invalid in this context

Posted in reply to KurtBremser

I Dont have AGE.sum as variable, but i want it to calculate 0.69 *age(sum of age)

is it possible?

Super User
Posts: 10,041

Re: The variable type of 'AGE.sum'n is invalid in this context

Posted in reply to imdickson

Yes. You can do it .

 

 

proc report data=sashelp.class nowd;
columns name sex age Yandhi;
define name/display;
define sex/display;
define age/analysis sum;
define Yandhi/computed;

compute before;
Age_sum=Age.sum;
endcomp;
compute Yandhi;
Yandhi = 0.69*Age_sum;
endcomp;
quit;
Super User
Super User
Posts: 7,976

Re: The variable type of 'AGE.sum'n is invalid in this context

Posted in reply to imdickson

Hi,

 

Have you tried putting "analysis" for age:

title'1st Proc Report';

proc report data=education003v5rightj out=reporteducation003 headline nowd split='*';
  column age startyear university yandhi;
  define age        / analysis 'Years/wasted in life' order;
  define startyear  / display "Commence year" width=10 left;
  define university / display  '*note*' width=5 flow;
  define yandhi     / computed 'Yandhi and Nathan' format=7.3;
  compute yandhi;
    yandhi = 0.69*age.sum;
  endcomp;
run;

Now I don;t have any test data to try it out, but something like that should work, and here is a helpful doc showing some examples:

http://www2.sas.com/proceedings/sugi27/p120-27.pdf

 

Also note, there is a {i} above where you post, this is to add code and keeps fomatting.  Please try to keep same capitiliasation in your programming, indentations matching - its far more important to write programs which other people can easily read.

Ask a Question
Discussion stats
  • 4 replies
  • 434 views
  • 0 likes
  • 4 in conversation