BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi!

Is there a wrapper that takes a script as input and outputs the same script but with "smart" linebreaks?

I typically upload scripts to a MVS host and would like to have a fixed linesize, however not splitting SAS statements etc.

Thanks
5 REPLIES 5
CurtisMack
Fluorite | Level 6
In what form are these scripts stored?
Cynthia_sas
SAS Super FREQ
And...by "script" do you mean JavaScript? A scripting language like Perl?? Or??? Also, do your "scripts" contain a complete SAS program or SAS program code snippets???

cynthia
DanielSantos
Barite | Level 11
By script, I'm assuming you are talking about a SAS program.

Anyway, the answer to your question, whatever your script maybe is no.
You'll have to code that yourself.

A macro with a more or less intelligent behavior could split the content of your files for the 80 char line limit, which exists on MVS.
The easiest way to do this would be to parse each line look for the nearest blank char ' ' under the 80 char limit, still this could produce some weird splits (say at the middle of constant value or expression).
Another way would be to parse to the nearest blank ' ', or ',' or ';', like the following code:

%let LIMIT=80;
%let INPUTF=c:\temp\myfile.sas;
%let OUTPUTF=c:\temp\myfile_&LIMIT..sas;

data _null_;
length INLINE $1024;
infile "&INPUTF";
file "&OUTPUTF";
input;
* under limit no line cut;
if length(_INFILE_) le &LIMIT then put _INFILE_;
else do; * try to cut the line;
INLINE=_INFILE_;
do while (length(INLINE) gt &LIMIT);
I=&LIMIT+1;
DLM='X';
do while (DLM not in (' ',',',';')); * line delimiters;
I=I-1;
if I = 0 then do;
put 'no valid delimiters where found, could not process line:';
put _INFILE_;
stop;
end;
* cut the line;
DLM=substr(INLINE,I,1);
INLINE=substr(INLINE,1,I);
end;
put INLINE;
INLINE=substr(INLINE,I+1);
end;
* check if the remaining is under limit;
if length(INLINE) le &LIMIT then do;
_INFILE_=INLINE;
output;
end;
end;
run;

Cheers from Portugal.

Daniel Santos @ www.cgd.pt
Peter_C
Rhodochrosite | Level 12
Dante

for example, see the SAS Sample 30649 last updated earlier this year, at http://support.sas.com/kb/30/649.html
Sample 30649: A SAS MACRO to Wrap Text

PeterC
deleted_user
Not applicable
Thanks for your input.

By script I mean a SAS program just like someone mentioned. The link posted by Peter seems what I'm looking for.

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
  • 5 replies
  • 638 views
  • 0 likes
  • 5 in conversation