| Date: | Tue, 1 May 2001 12:31:18 +0100 |
| Reply-To: | Peter Crawford <Peter@CRAWFORDSOFTWARE.DEMON.CO.UK> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | Peter Crawford <Peter@CRAWFORDSOFTWARE.DEMON.CO.UK> |
| Organization: | Crawford Software Consultancy Limited |
| Subject: | Re: Read CSV and manip' |
HI Graeme
You have provided only one data example
If the general structure is like
prefix1:string1:string2, prefix2:string3:string4=value, string5
then you could simplify extraction of the parts using function scan()
like
data WORK.body ;
infile 'C:\WINNT\Profiles\gkirton\Desktop\ESM001A-00-0138.csv'
delimiter =',' MISSOVER DSD
lrecl=32767
firstobs=16 obs=185;
length VAR1-var3 $97. prefix1-prefix2 string1-string4 $25;
input VAR1-var3 ;
prefix1 = scan( var1, 1, ':' );
prefix2 = scan( var2, 1, ':' );
string1 = scan( var1, 2, ':' );
string2 = scan( var1, 3, ':' );
string3 = scan( var2, 2, ':=' );
value = input( scan( var2, 2, '=' ), ?? best32. );
string4 = scan( var3, 1, ':' );
run;
but it all depends on the variety of data structure,
whether this method is superior to any other.
Good luck
Graeme Kirton <gkirton@FILCS.COM> writes
>
>
>Hi Folks, a little help reading in a csv file(s) I have. I read in the file as
>below, only the parameter part takes the bit in BOLD. I want parameter to read
>the part thats also in italic. I dont want to change my delimiter on the INFILE
>for obvious reasons. Anyhelp appreciated???
>
>data WORK.body (drop=comp var1);
> infile 'C:\WINNT\Profiles\gkirton\Desktop\ESM001A-00-0138.csv' delimiter =
>',' MISSOVER DSD lrecl=32767 firstobs=16 obs=185;
> format VAR1 $97. ;
> format Shot1-Shot64 best12. ;
>
> informat VAR1 $97. ;
> informat Shot1-Shot64 best32. ;
> input
> VAR1 $
> Shot1-Shot64;
> comp=compress(var1,' ');
> Parameter=scan(comp,2,',');
> run;
>
>
>PARAMETER..................................
>(Embedded image moved to file: pic25205.pcx)
Don't like this
>
>
>Thanx
>Graeme
>________________________
>
>Disclaimer
>
--
Peter Crawford
|