The SAS Output Delivery System and reporting techniques

ASCII Question ASAP

Accepted Solution Solved
Reply
Regular Contributor
Posts: 155
Accepted Solution

ASCII Question ASAP

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.


Accepted Solutions
Solution
‎05-03-2013 06:20 PM
SAS Super FREQ
Posts: 8,721

Re: ASCII Question ASAP

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;

View solution in original post

Attachment

All Replies
Super User
Super User
Posts: 6,368

Re: ASCII Question ASAP

Set a SPLIT character?

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

...

compute Address /character length=250

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

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

SAS Super FREQ
Posts: 8,721

Re: ASCII Question ASAP

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

Regular Contributor
Posts: 155

Re: ASCII Question ASAP

Hey Cynthia,

I am using ODS LISTING DESTINATION = Report.asc

Solution
‎05-03-2013 06:20 PM
SAS Super FREQ
Posts: 8,721

Re: ASCII Question ASAP

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;

Attachment
Regular Contributor
Posts: 155

Re: ASCII Question ASAP

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

SAS Super FREQ
Posts: 8,721

Re: ASCII Question ASAP

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

Regular Contributor
Posts: 155

Re: ASCII Question ASAP

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.

Regular Contributor
Posts: 155

Re: ASCII Question ASAP

Hey Cynthia,

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

I used Macro Variable and compute block to print it.

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 8 replies
  • 392 views
  • 0 likes
  • 3 in conversation