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.
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;
Set a SPLIT character?
proc report ... SPLIT='|' ... ;
...
compute Address /character length=250
ADDRESS=trim(left( ADDR1))||"|" ||trim(left( ADDR2))
||"|" || trim(left( add3)) ;
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
Hey Cynthia,
I am using ODS LISTING DESTINATION = Report.asc
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;
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
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
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.
Hey Cynthia,
I got it.Thanks for the help with Width and flow option.
I used Macro Variable and compute block to print it.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.