|
Hi Mike,
* make sample data ;
data _null_;
file 'c:\temp\abc.txt';
put 'test1@dkadk.com';
put '3234dk@efg.com';
put 'jieuw@lmdkadk.com';
put '3234dk@efg.com';
run;
* Read variable line length flat file ;
data table1(keep=myline);
length myline $ 200;
infile 'c:\temp\abc.txt' length=lenvar;
input @1 myline $varying. lenvar;
run;
* adding your goodies ;
data table1(keep=email domain);
length email $ 50;
infile 'c:\temp\abc.txt' length=lenvar;
input @1 email $varying. lenvar;
email = left(trim(lowcase(email))) ;
domain = substr(email,(index(email,'@')+1)) ;
run;
* another variation using SCAN() ;
* to replace INDEX() and SUBSTR() ;
data table1(keep=email domain);
length email $50;
infile 'c:\temp\abc.txt' length=lenvar;
input @1 email $varying. lenvar;
email = left(trim(lowcase(email))) ;
domain = scan(email,2,'@') ;
run;
Hope this is helpful,
Mark Terjeson
Washington State Department of Social and Health Services
Division of Research and Data Analysis (RDA)
mailto:terjemw@dshs.wa.gov
-----Original Message-----
From: Mike Stuart [mailto:muon33@NYC.RR.COM]
Sent: Wednesday, October 03, 2001 9:29 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Text File Import Problem
Having problems with a straight-forward import, I think the problem
has to do with non-viz characters, but I'm not sure. When viewed, the
file I'm trying to read in is relatively straight-forward, one email
address per line. I'm using the code below to read in this file.
data ffx.epilist ;
infile epilist truncover ;
input @1 email $50. ;
email = left(trim(lowcase(email))) ;
domain = substr(email,(index(email,'@')+1)) ;
run ;
The output however looks like this:
obs email domain
1 test1@dkadk.com 3234dk@efg.com jieuw@lm dkadk.com
3234dk@efg.com
etc.
It looks like the line delimiter is missing. Suggestions on how to
fix? I've tried the import wizard using a number of different
delimiter option and am getting the same result.
Thanks -
|