Date: Thu, 18 Dec 2008 12:09:44 -0800
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Shiling Zhang <shiling99@YAHOO.COM>
Subject: Re: Space and Double-tilda( ~~) delimited file
Content-Type: text/plain; charset=ISO-8859-1
On Dec 18, 2:46 pm, baymanl <baym...@gmail.com> wrote:
> Hi all,
> We obtained some datasets from a third party and the data are
> delimited with space-tilda-tilda ( ~~), and some (but not all) missing
> entries are underscores (_). I cannot import them into SAS properly.
> What I have tried:
> 1 - importing directly into SAS. If I do this by indicating the
> delimiter is " ~~" then I get one extra column for each second tilda.
> (160 variables instead of 80). Also many errors due to ~ and _'s.
> 2 - import to Access -> import to SAS. I get better structure, only
> couple empty columns, but almost all the variables are 255 character
> 3 - open the data in a text editor -> find/replace " ~~" with commas,
> replace _ with space -> import to SAS as CSV. It's the most
> cumbersome, but seems like the best way. Except, I cannot indicate
> some variables are in fact texts (patients ID numbers, etc), and they
> are in numeric format after importing which creates problems with the
> current SAS codes.
> Have you had any similar problem, and how did you manage importing?
> Thanks a lot.
You may consider to write your own inport pgm. Here is an example and
you can modify it for your use.
length x $1;
infile cards delimiter=' ~' truncover;
input x y z;
1 ~~_ ~~3
1 ~2 ~~3
1 2 3
proc print; run;