Date: Fri, 18 May 2012 06:08:00 -0500
Reply-To: "Data _null_;" <iebupdte@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Data _null_;" <iebupdte@GMAIL.COM>
Subject: Re: insert blanks
In-Reply-To: <000b01cd3489$a99e7330$fcdb5990$@com>
Content-Type: text/plain; charset=ISO-8859-1
If your goal is to use SCAN function with consecutive delimiters as in
INFILE option DSD there is an option for that.
m or M specifies that multiple consecutive delimiters, and delimiters
at the beginning or end of the string argument, refer to words that
have a length of zero. If the M modifier is not specified, then
multiple consecutive delimiters are treated as one delimiter, and
delimiters at the beginning or end of the string argument are ignored.
On 5/17/12, bbser 2009 <bbser2009@gmail.com> wrote:
> Ha, that's exactly the idea I would like to explore when I said you reminded
> me of something. What a coincidence!
> I guess it much efficient than using so many scan and input functions. I
> will test it on the raw data after finishing my project and write back.
>
> Q: Why the first line of the output data set is 10 20 ...?
>
> -----Original Message-----
> From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
> Nordlund, Dan (DSHS/RDA)
> Sent: May-17-12 7:12 PM
> To: SAS-L@LISTSERV.UGA.EDU
> Subject: Re: [SAS-L] insert blanks
>
>> -----Original Message-----
>> From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
>> bbser 2009
>> Sent: Thursday, May 17, 2012 3:11 PM
>> To: SAS-L@LISTSERV.UGA.EDU
>> Subject: Re: insert blanks
>>
>> Thank you, Dan. I used the method you mentioned. Then I found I had to
>> switch to using _infile_ to deal with messy data as quite a few other
>> guys suggest me.
>> Anyway, your comment reminded me about something. I might come back to
>> this topic later.
>>
>> Max
>>
>
> Well, I haven't followed all the conversation as closely as I maybe should
> have if I am going to make suggestions, ... but I'll go ahead and make
> another one. :-) Using _infile_ processing does not mean you can't use the
> DSD option. Here is a simple example of what I mean. I change _infile_
> only on the first iteration just to keep things simple.
>
> data test;
> infile cards dlm=":" dsd;
> input @;
> put _infile_;
> if _n_ = 1 then _infile_='10:20:30:40';
> input a b c d;
> cards;
> 1:::
> :2::
> ::3:
> :::4
> ;
> run;
> proc print;
> run;
>
> You can see that _infile_ can be manipulated and the DSD option still works.
> So maybe you could make this work for you. If not, then "no harm, no
> foul.'
>
>
> Hope this is helpful,
>
> Dan
>
> Daniel J. Nordlund
> Washington State Department of Social and Health Services
> Planning, Performance, and Accountability
> Research and Data Analysis Division
> Olympia, WA 98504-5204
>
|