BookmarkSubscribeRSS Feed
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)*/


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;



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 i doing something wrong?

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?

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;
compute Yandhi;
Yandhi = 0.69*Age_sum;
Diamond | Level 26 RW9
Diamond | Level 26



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;

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:


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.

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;


if agecat.sum<12 then do;

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

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

where  age<=12;


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.


Diamond | Level 26 RW9
Diamond | Level 26

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



Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

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.

Get the $99 certification deal.jpg



Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 5 in conversation