BookmarkSubscribeRSS Feed
imdickson
Quartz | Level 8

 

 

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?

6 REPLIES 6
imdickson
Quartz | Level 8

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

is it possible?

Ksharp
Super User

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;
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

Varrelle
Quartz | Level 8

My goal is to suppress one of the columns nested inside an across variable in PROC REPORT, conditional on a specified value of the across variable.

 

To understand this, I used the sashelp.class dataset.  I limited age to LE 12 so that only ages 11 and 12 would display.  age is also the across variable and nested within age are sex, weight, and height.  For this example, I want to "noprint"/suppress/hide the sex column when the age across variable = 11, but otherwise print the sex column for the other columns (age=12 for this example).

 

What follows is the code I wrote to try to accomplish this:

 

proc report data=sashelp.class nowd;
column name age,(sex weight height) age=agecat dummyvar;
define name/order;
define age/ across;
define agecat/analysis sum;
define sex/across;
define weight/display;
define height/display;
define dummyvar/noprint;
compute dummyvar;

dummyvar=1;

if agecat.sum<12 then do;

call define ("_c2_","style","style={width=0}");

call define ("_c3_","style","style=[width=0]");

end;
endcomp;
where  age<=12;
run;

 

my log displays the following messages:

ERROR: The variable type of AGECAT.SUM is invalid in this context.
NOTE: The preceding messages refer to the COMPUTE block for dummyvar.
NOTE: Will not run due to compilation errors.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: There were 7 observations read from the data set SASHELP.CLASS.
      WHERE age<=12;

 

Is what I am trying to accomplish possible? If so, could some one provide code that could accomplish my objective? Thanks.

 

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Please start a new thread with your question, this thread is a couple of years old.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 3167 views
  • 0 likes
  • 5 in conversation