LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (November 2005, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
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
Comments: To: sas-l@uga.edu

Rajat Mathur wrote:

> Actually, my raw data is something like this: > ID,SOURCE,Var1,Var2......V275 > > 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.

data foo; 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[*] ;

drop char:; cards; 1,a,b,c,3,4,5 2,a,z,5,4,3 3,a,b,c,d,e,f,12,34,56 run;

-- Richard A. DeVenezia http://www.devenezia.com/


Back to: Top of message | Previous page | Main SAS-L page