BookmarkSubscribeRSS Feed
deleted_user
Not applicable
COMPUTE AFTER k;
LINE ' ';
lx1=length("&yy1doll");
if lx1 less than 6 then
LINE @01 "&cur_mon-MONTH TOTAL" @36 "&yy2doll"
@53 "&yy2pct" @85 "&yy1doll" @101 "&yy1pct";
LINE ' ';
ENDCOMP;

But it seems the condition is not being checked and the LINE statement is displayed even when the number of digits is greater than 6.

Can you please help me with this?? Or is there any other option to display the data with exact alignment as i mentioned??Please reply ASAP.

Thanks,
Sandhya
Cynthia_sas
SAS Super FREQ
Hi:
With PROC REPORT, you can not use a LINE statement conditionally. That means you have to make a temporary variable with the value of the line for each condition and then you ALWAYS write out the temporary variable. The program below is a variation of your logic: [pre]
ods listing;
ods html file='c:\temp\cond_line.html' style=sasweb;
ods pdf file='c:\temp\cond_line.pdf';
ods rtf file='c:\temp\cond_line.rtf';
proc report data=sashelp.shoes nowd
style(lines)={just=l};
title "A conditional LINE statement";
column region product sales;
where product in ('Sandal', 'Slipper') and
region in ('Asia', 'United States', 'Pacific');
define region / group;
define product / group;
define sales/ sum f=dollar14.;
break after region /summarize skip;

COMPUTE AFTER region;
holdline = repeat(' ',100);;
holdsale = trim(left(put(sales.sum,dollar14.)));

if sales.sum lt 400000 then
holdline = 'LT: iiiii lllll jjjjj ' ||holdsale;
else if sales.sum ge 400000 then
holdline = 'GE: wwwww xxxxx yyyyy ' ||holdsale;
LINE holdline $100.;
ENDCOMP;
run;
ods _all_ close;
[/pre]

In the listing window, the output looks like this:
[pre]
A conditional LINE statement

Region Product Total Sales
Asia Sandal $8,208
Slipper $152,032
Asia $160,240
LT: iiiii lllll jjjjj $160,240

Pacific Sandal $48,424
Slipper $390,740
Pacific $439,164
GE: wwwww xxxxx yyyyy $439,164

United States Sandal $12,039
Slipper $967,927
United States $979,966
GE: wwwww xxxxx yyyyy $979,966

[/pre]
Which DOES get you the conditional line information. Note, how in the LISTING window, the letter 'i' is lined up with the letter 'w' -- the same results would have been achieved if I had used the '@' method. However, when the output is sent to RTF, PDF or HTML, the '@' in the LINE statement WILL NOT work. The reason it will not work is the same reason that the 'i' is NOT lined up with the 'w' in RTF, PDF and HTML output -- because ODS uses a proportional spaced font and so @13 on one line will be different than @13 on a second line, depending on what you've already written to the line.

When I explained in previous posts that the PUT statement did not work with ODS in the same way that it worked in the LISTING window, that same explanation also applies to the LINE statement. There is no good way to get the "exact" alignment that you want except in the LISTING window.

This means that you will have to write your output to the LISTING destination in order to get "exact" alignment and then use some other means (not ODS) to create a PDF file (such as a 3rd party Text-to-PDF converter).

Good luck!
cynthia
deleted_user
Not applicable
Hi ,

Can you help me with this??
I have used the following proc fromat for displaying some percentage values with + or - in decimals.(Eg: +7.7 , -0.8 etc).

PROC FORMAT;
PICTURE plusmin low -< 0 = '0,009.9' ( prefix = '- ' )
0 <- high = '0,009.9' ( prefix = '+ ' )
;

But this proc format works only for values greater than or less than 0. But i need to display the format for the value 0 also.( like +0.0 or -0.0).
How can i acheive this??
Please help me ASAP.

Thanks,
Sandhya

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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
  • 17 replies
  • 3158 views
  • 0 likes
  • 2 in conversation