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

Hi All,

I am using Proc Report and generating an ASCII file

Previously when generating PDF files i used options like

compute Address /character length=250

ADDRESS=trim(left( ADDR1))||"~{newline}" ||trim(left( ADDR2))

||"~{newline}" || trim(left( add3)) ;

So when it prints

Address

Addr1

Addr2

Addr3

But the {newline} option is not working for ASCii Files.Is there any option for splitting it in ASCII

Previously i was using ODS PDF TEXT="end of report" ASA option but this will not work for ASCII.

Is there any other option like this which i can use to print in the end of the report.

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

Hi:

  Well, I was able to make it work with ODS LISTING using WIDTH and FLOW. See the attached screen shot and the difference between NEWVAR and NEWVAR2, where the SPLIT character is used.

cynthia

data class;
  set sashelp.class;
  length newvar $60;
  newvar=catx('*',name,sex,put(age,2.0));
run;

 

options ls=180;
ods listing file='c:\temp\report.asc';
proc report data=class nowd split='*' nocenter ls=100;
  column name age sex newvar newvar2 height weight;
  define newvar / width=12 flow;
  define newvar2 / computed width=15 flow;
  compute newvar2 / character length=60;
    newvar2= trim(name)||' ~ '||trim(sex)||'*'||left(put(age.sum,2.0));
  endcomp;
run;


pix_report_asc.png

View solution in original post

8 REPLIES 8
Tom
Super User Tom
Super User

Set a SPLIT character?

proc report ... SPLIT='|' ... ;

...

compute Address /character length=250

ADDRESS=trim(left( ADDR1))||"|" ||trim(left( ADDR2))

||"|" || trim(left( add3)) ;

Cynthia_sas
SAS Super FREQ

Hi,

   The SPLIT option by default splits the column headers on the report. If you are using the LISTING destination, then you can add FLOW to the DEFINE statement to make the SPLIT character work within a data value.

  But the OP didn't say they were using ODS LISTING to make an ASCII text file. For example, a CSV file, an HTML file and an XML file are all ASCII text files. The ODS LISTING destination can also be used to make an ASCII text file. So, depending on the ODS destination that the OP is using, the SPLIT with FLOW may or may not work.

cynthia

JasonNC
Quartz | Level 8

Hey Cynthia,

I am using ODS LISTING DESTINATION = Report.asc

Cynthia_sas
SAS Super FREQ

Hi:

  Well, I was able to make it work with ODS LISTING using WIDTH and FLOW. See the attached screen shot and the difference between NEWVAR and NEWVAR2, where the SPLIT character is used.

cynthia

data class;
  set sashelp.class;
  length newvar $60;
  newvar=catx('*',name,sex,put(age,2.0));
run;

 

options ls=180;
ods listing file='c:\temp\report.asc';
proc report data=class nowd split='*' nocenter ls=100;
  column name age sex newvar newvar2 height weight;
  define newvar / width=12 flow;
  define newvar2 / computed width=15 flow;
  compute newvar2 / character length=60;
    newvar2= trim(name)||' ~ '||trim(sex)||'*'||left(put(age.sum,2.0));
  endcomp;
run;


pix_report_asc.png
JasonNC
Quartz | Level 8

Hey Cynthia,

The flow option worked .Thanks!!!!!

One more question

For PDF we have an option to print

ODS PDF TEXT=****END OF REPORT ****

Is there any option like this for ASCII files.

I want to print it in the last page.

I will appreciate your help

Cynthia_sas
SAS Super FREQ

Hi:

  Put this COMPUTE block in your PROC REPORT code. It will only be written at the end of the report. ODS TEXT does not work for the LISTING destination.

  compute after;

    line '*** End of Report ***';

  endcomp;

cynthia

JasonNC
Quartz | Level 8

Hey Cynthia,

I used it but the problem is it is printing the End of Report in next page.I have a page break on Break after Variable / PAGE.

It is going to the next page printing the headers and then printing the end of report.

It should print in the same page.

JasonNC
Quartz | Level 8

Hey Cynthia,

I got it.Thanks for the help with Width and flow option.

I used Macro Variable and compute block to print it.

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