BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
JuanVte
Calcite | Level 5

Hello,

In the LISTING destination, does anyone knows how to separate blocks with a line without the need of specifying the length?

The following code only works for the first 2 pages, but for the last one, the line is too long.

proc report data=sashelp.cars nowd ls=100 headline nocenter;

where Make in ('Acura','Cadillac');

columns ("--" Make--Length);

define make / order id;

define model / order id width=20;

compute after make;

line @3 "-------------------------------------------------------------------------------------------";

endcomp;

compute after;

line @3 "my footnote which will contain the page number,";

line @3 "the output name and other useful information.";

endcomp;

run;

I need something that works automatically because this code is for a macro which should handle several situations.  Something like "--" in the column statement would be perfect, but as far as I know there is nothing similar in the compute statement.

This is the best I got, but it only adds lines under numeric variables, and adds empty space between columns.

proc report data=sashelp.cars nowd ls=100 headline nocenter width=100;

where Make in ('Acura','Cadillac');

columns ("--" Make--Length);

define make / order id;

define model / order id width=20;

break after make / ol;

compute after;

line @3 "my footnote which will contain the page number,";

line @3 "the output name and other useful information.";

endcomp;

run;

Thanks!!

Juan

1 ACCEPTED SOLUTION

Accepted Solutions
data_null__
Jade | Level 19

With destination LISTING you have the "luxury" of being able to post-process the file with relative ease.

This example assumes that the first line is the spanning header that is the full width of the output.  If you measure this line you can use that measurement to trim the LINE statement output that is too long.

For more complex output you will need alternative ways to find the optimal page with.

options number=0 center=1 date=0 ls=255;
filename FT74F001 temp;
ods listing file=FT74F001;
%let ls=100;
title1; footnote1;
proc report data=sashelp.cars ls=&ls nowd headline nocenter list;
  
where Make in ('Acura','Cadillac');
   columns ("--" Make--Length);
   define make / order id;
  
define model / order id width=20;
  
compute after make;
      line @3 %eval(&ls-3)*'-'; /*These line will be trimmed after we figure the correct length*/
  
endcomp;
  
compute after;
  
line @3 "my footnote which will contain the page number,";
  
line @3 "the output name and other useful information.";
  
endcomp;
  
run;
ods listing close;
ods listing;

/*data _null_;*/
/*   infile FT74F001;*/
/*   input;*/
/*   list;*/
/*   run;*/
Title 'Add title in this step';
Title2 'Add title2 in this step';

data _null_;
  
file print nofootnote ls=&ls;
   infile FT74F001 noprint;
  
input;
   np=first(_infile_) eq
'0C'x;
  
if _n_ eq 1 or np then do;
     
if np then do;
         _infile_ = substr(_infile_,
2);
         put _page_ @;
         end;
      l=length(_infile_);
     
put _infile_;
     
end;
  
else put _infile_ $varying256. l;
   retain l;
   run;

View solution in original post

4 REPLIES 4
Peter_C
Rhodochrosite | Level 12

LINE %SYSFUNC(  GETOPTION( LS))*'-' ;

JuanVte
Calcite | Level 5

Thanks Peter,

I believe this only works if I use the whole line size for my report, which is not the case. Besides, this would set the same line length for all pages in the report. In my case, the width of the report is different among pages.

Any other idea? I starting to believe that there is no simple answer to this basic requirement.

data_null__
Jade | Level 19

With destination LISTING you have the "luxury" of being able to post-process the file with relative ease.

This example assumes that the first line is the spanning header that is the full width of the output.  If you measure this line you can use that measurement to trim the LINE statement output that is too long.

For more complex output you will need alternative ways to find the optimal page with.

options number=0 center=1 date=0 ls=255;
filename FT74F001 temp;
ods listing file=FT74F001;
%let ls=100;
title1; footnote1;
proc report data=sashelp.cars ls=&ls nowd headline nocenter list;
  
where Make in ('Acura','Cadillac');
   columns ("--" Make--Length);
   define make / order id;
  
define model / order id width=20;
  
compute after make;
      line @3 %eval(&ls-3)*'-'; /*These line will be trimmed after we figure the correct length*/
  
endcomp;
  
compute after;
  
line @3 "my footnote which will contain the page number,";
  
line @3 "the output name and other useful information.";
  
endcomp;
  
run;
ods listing close;
ods listing;

/*data _null_;*/
/*   infile FT74F001;*/
/*   input;*/
/*   list;*/
/*   run;*/
Title 'Add title in this step';
Title2 'Add title2 in this step';

data _null_;
  
file print nofootnote ls=&ls;
   infile FT74F001 noprint;
  
input;
   np=first(_infile_) eq
'0C'x;
  
if _n_ eq 1 or np then do;
     
if np then do;
         _infile_ = substr(_infile_,
2);
         put _page_ @;
         end;
      l=length(_infile_);
     
put _infile_;
     
end;
  
else put _infile_ $varying256. l;
   retain l;
   run;
JuanVte
Calcite | Level 5

Trimming the output, that was very smart.

I am very impressed, thanks. I will try to adapt it to use in my macro.

Regards, Juan

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!

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.

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
  • 4 replies
  • 1766 views
  • 0 likes
  • 3 in conversation