Date: Fri, 11 Nov 2005 23:05:02 -0500
Reply-To: "Richard A. DeVenezia" <radevenz@IX.NETCOM.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Richard A. DeVenezia" <radevenz@IX.NETCOM.COM>
Subject: Re: How to read a CSV file from right to left
Rajat Mathur wrote:
> Actually, my raw data is something like this:
> The Id is unique but unfortunately the SOURCE contains values which
> are comma separated. So my code to import to SAS go for a toss as for
> one observation there can be three source while in other there can be
> 20 source. And in my raw file the values for each variable is not
> enclosed within quotes("").
> However I don't want this variable (SOURCE) in my analysis.
> So I was wondering if I can read the data from V275 till V1 and drop
> the rest. By conventional method I can read ID. In these two obtained
> data I shall put a new ID which is nothing but the observation number
> and shall merge with this new ID to get my desired Dataset.
> Can anyone help me on this issue?
Try to decipher this fun sample.
retain id v1-v3 char1-char3;
array cval[*] $32 char3-char1;
array nval[*] 8 v1-v3;
infile cards dsd dlm=',' _infile_=buffer1 ;
file "NUL:" _file_=buffer2;
input @1 id @;
buffer1 = left(reverse(_infile_));
input @1 (cval[*]) ($revers12.:) @;
buffer2 = '';
put @1 (char:)(',') @;
buffer1 = buffer2;
input @2 nval[*] ;
Richard A. DeVenezia