| Date: | Thu, 4 Aug 2005 11:17:35 -0400 |
| Reply-To: | Randy Herbison <RandyHerbison@WESTAT.COM> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | Randy Herbison <RandyHerbison@WESTAT.COM> |
| Subject: | Re: please help convert text notes to SAS |
|
| Content-Type: | text/plain; charset="us-ascii" |
Nancy,
If I understand your objective correctly, there are many problems with
the program you listed.
You do not need to specify variables on the INPUT statement to retain
the content of _infile_ across observations.
The DSD option doesn't do anything here. It applies to LIST input.
Since you do not need to specify variables on the INPUT statement,
MISSOVER and PAD are not needed.
The LENGTH statement specifies the variable NOTES, but later in the
program you use NOTE. NOTES never gets a value.
Why right-justify VALUE?
Because you first specify allnotes in a RETAIN statement without a $,
allnotes defaults to numeric, and ends up with all missing data.
The COMPBL function, as used in your program, gets rid of multiple
blanks in the concatenated value. You need to trim the value on the
left side of the concatenation operator first.
I would rewrite your program as:
data allNotes;
length allNotes $ 32767;
infile "c:\test.txt" lrecl=1024;
retain allNotes;
input;
allNotes=trim(allnotes) || _infile_;
run;
RandyHerbison@westat.com
-----Original Message-----
From: owner-sas-l@listserv.uga.edu [mailto:owner-sas-l@listserv.uga.edu]
On Behalf Of Nancy Li
Sent: Thursday, August 04, 2005 10:15 AM
To: sas-l@listserv.uga.edu
Subject: RE: please help convert text notes to SAS
Thank you for those who replied to my question. I combined all your
suggestions together and use the following code, it works well.
Thanks again!
Nancy
data one;
length notes $1500;
infile 'C:\test.txt' dsd missover lrecl=1500 pad;
input value $1500.;
note=right(value);
retain allnotes;
allnotes=compbl(allnotes || note);
put allnotes;
run;
Randy Herbison <RandyHerbison@westat.com> wrote:
Nancy,
If you have leading blanks in the text, and you would like to retain the
leading blanks, then change the assignment statement to:
value = trim(value) || _infile_;
If you do not wish to retain leading blanks, then left justify _infile_:
value = trim(value) || left(_infile_);
RandyHerbison@westat.com
-----Original Message-----
From: owner-sas-l@listserv.uga.edu [mailto:owner-sas-l@listserv.uga.edu]
On Behalf Of Nancy Li
Sent: Wednesday, August 03, 2005 4:46 PM
To: sas-l@listserv.uga.edu
Subject: please help convert text notes to SAS
I have a text file with multiple lines, I would like to convert this
text file to SAS and make these multiple lines notes into one variable.
I used the following code, but it doesn't work as what I expected. Can
anybody help me with this? Thanks!
data _null_;
length value $2000;
infile 'C:\test.txt' dsd missover lrecl=1500;
input;
retain value;
value = trim(left(value || _infile_));
put value;
run;
Nancy
The text notes are as the following:
Is on Section 8 has 2 PCA is covered except 3-4 hours/day
- has fallen ? if possable fall a call alert alarm
- W/C bound unable to bear wt.related to spinal cord surgery @ level
C-4&5 only has minimal use of both upper extremities
lives in a 2 story apt. -bums her way up the stairs ( her wt is 290 )
discussed electric chair for stairs - landlord would not approve -
discussed other independent living apts -states she has looked into it
but has an 11yo chow and any housing she found that would accept animals
would not accept a chow.
also had some transportation issues stated often would have to wait 3-4
hours for ride
would be interested in one level living that would accept dog
* is not willing to give up dog to move
thank you
Cindy
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
|