Re: Put to split a string into two lines ?

  • Follow


He isn't asking that; he's asking how to put it out to the log without
separate variables.

Ya,  I don't know of a way to do this.  PUT doesn't operate on (most?)
functions.  You might be able to use some %sysfunc stuff to work around
that, but it would be much messier than splitting it into variables first.

-Joe

On Fri, Jan 22, 2010 at 2:49 PM, SD_Data_Dude <thompsop@sanfordhealth.org>wrote:

> On Jan 22, 1:28 pm, ya.hu...@AMYLIN.COM (Ya Huang) wrote:
> > Hi there,
> >
> > I have a long string, which has one or more '/' in between the letters,
> > is there a way to use put statement and get two lines?
> >
> > 9    data _null_;
> > 10   a='first line / second line';
> > 11   put a=;
> > 12   run;
> >
> > a=first line / second line
> > NOTE: DATA statement used (Total process time):
> >
> > I would like the following though:
> >
> > a=first line
> > second line
> >
> > I can certainly break the string apart, and use put like this
> > put st1 / st2 / st3...
> > Just wondering if it can be done more easily like split='/' in proc
> > report?
> >
> > Thanks
> >
> > Ya
>
> Learn about the scan function.
>
0
Reply snoopy369 (1752) 1/22/2010 8:57:04 PM

On Jan 22, 2:57=A0pm, snoopy...@GMAIL.COM (Joe Matise) wrote:
> He isn't asking that; he's asking how to put it out to the log without
> separate variables.
>
> Ya, =A0I don't know of a way to do this. =A0PUT doesn't operate on (most?=
)
> functions. =A0You might be able to use some %sysfunc stuff to work around
> that, but it would be much messier than splitting it into variables first=
..
>
> -Joe
>
> On Fri, Jan 22, 2010 at 2:49 PM, SD_Data_Dude <thomp...@sanfordhealth.org=
>wrote:
>
> > On Jan 22, 1:28 pm, ya.hu...@AMYLIN.COM (Ya Huang) wrote:
> > > Hi there,
>
> > > I have a long string, which has one or more '/' in between the letter=
s,
> > > is there a way to use put statement and get two lines?
>
> > > 9 =A0 =A0data _null_;
> > > 10 =A0 a=3D'first line / second line';
> > > 11 =A0 put a=3D;
> > > 12 =A0 run;
>
> > > a=3Dfirst line / second line
> > > NOTE: DATA statement used (Total process time):
>
> > > I would like the following though:
>
> > > a=3Dfirst line
> > > second line
>
> > > I can certainly break the string apart, and use put like this
> > > put st1 / st2 / st3...
> > > Just wondering if it can be done more easily like split=3D'/' in proc
> > > report?
>
> > > Thanks
>
> > > Ya
>
> > Learn about the scan function.

This is very easy to do.  You write your own put function, using the
macro system and the scan function and the put statement.

To use SAS well, you must think outside the box.

%macro myput(_strx=3D);
%let i=3D1;
%let cont=3D1;
%do %while(&cont);
tprstr=3Dscan(&_strx,'/');
%if (%length(tprstr) > 1) %then %do;
put tprstr;
%let i=3D%eval(i+1);
%end;
%else %let cont=3D0;
%end;
%mend myput;

that won't work but can get you started.
0
Reply SD_Data_Dude 1/22/2010 9:19:51 PM


1 Replies
537 Views

(page loaded in 0.064 seconds)

Similiar Articles:













7/24/2012 4:54:17 PM


Reply: