BookmarkSubscribeRSS Feed
ANIRBAN2
Fluorite | Level 6

ANIRBAN2_0-1649254634287.png

I wanted to remove the last value taken during and the year end.

 

ods escapechar="^";
proc report data=sashelp.shoes spanrows split='#' out=abcd
style(header)=[foreground=BLACK background=ORANGE font_size=10pt font_weight=bold vjust=bottom]
style(report)=[cellspacing=2 cellpadding=10 borderwidth=1 bordercolor=black outputwidth=100% font_face=calibri font_weight=bold frame=box ];
title 'A2) Default Report Only Numeric Variables';
title2 'With COMPUTE block for new report items';
column region product sales returns inventory Profit pctinv ;
define region/display "REG" group style(column)=[vjust=center just=CENTER font_size=15pt cellwidth=0in backgroundcolor=yellow font_weight=bold] ;
define product /display format=$50. "PRO" group ;
define profit / computed f=dollar14.2 style(header)=[just=center background=blue] style(column)=[just=center font_size=10pt];
define pctinv /computed display "%" computed f=percent9.2 style(header)=[just=center background=blue] style(column)=[just=center font_size=10pt];

compute pctinv;
profit = sum(sales.sum,-1*returns.sum);
pctinv = sales.sum/ inventory.sum;
endcomp;

Compute Region;
If Region='Central America/Caribbean' and _BREAK_ ="Region" then Region='USA';
line region $varying100.;
brktxt = ' ';
text1='^{style[textdecoration=underline just=CENTER]Values taken during } ';
text2='the Year End.';
if region = 'Canada' then do;
reglg = 0;
reglg2 = 0;
reglg3 = 0;
end;
else do;
reglg = 1;
reglg2 = 20;
reglg3 = 20;
end;
endcomp;

break after region/summarize style={font_weight=bold font_size=10pt background=pink just=CENTER };

 

compute after region/ style={background=white};
line brktxt $varying. reglg;
line text1 $varying. reglg2; ;
line text2 $varying. reglg3;;
endcomp;

/* compute after region /style={ background=white}; */
/* line ' '; */
/* line @20 '^{style[textdecoration=underline just=CENTER]Values taken during } ' ; */
/* line @20 'the Year End.'; */
/* endcomp; */
rbreak after /summarize skip ul ol style={font_weight=bold font_size=10pt background=pink just=center};

/* line '^{style[foreground=white]Values taken during } ' */
Compute after/style={background=white just=CENTER };
Product="GRAND TOTAL of countries " ; /*HOW TO PUT THE TOTAL TEXT AND MAKE BOLD*/
REgion="GRAND";
line @50 "THIS IS FROM ALL OVER THE WORLD";
Endcomp;

Footnote 'This is a system generated mail please dont respond to this ';
run;

 

 

THE ERROR I AM GETTING

ANIRBAN2_1-1649254858035.png

 

2 REPLIES 2
ChrisNZ
Tourmaline | Level 20

1 Please format your code when pasting it by using the apropriate icon

 

2 Not too sure what your goal is.

Do you want to replace the line statement with this?

  compute before REGION;
    line REGION $100.;
  endcomp;

 

Cynthia_sas
SAS Super FREQ

Hi:

  You have a LINE statement in the COMPUTE block for REGION. That won't work. PROC REPORT executes the COMPUTE block for the REGION column on EVERY row for EVERY value of REGION. PROC REPORT won't write your LINE statement on EVERY row. That's the meaning of the message. You can only use the LINE statement in a COMPUTE block that's associated with a "break" location, like BEFORE, or AFTER or at the top of the report or the bottom of the report. I think you might want your LINE in a COMPUTE BEFORE REGION??? Not sure exactly what you're trying to do or why you're changing the Region from Central America into USA, that doesn't make sense.

  I don't understand why you can't remove the lines you want because you create the temporary variables TEXT1 and TEXT2 and then use those variables in LINE statements. If you want to remove them, change the LINE statements.

Cynthia

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

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

View all other training opportunities.

Discussion stats
  • 2 replies
  • 253 views
  • 0 likes
  • 3 in conversation