|
Gary,
It is a bit harder than this because he doesn't want words split. When I ran
your program, VAR3 began with "here". It should have been "where".
There have been a number of SUGI papers on the topic over the years. The only
one I remember at the moment that is easily available is one by Dave Riba and
can be found at his web site http:\\www.jadetek.com.
Ian Whitlock <whitloi1@westat.com>
____________________Reply Separator____________________
Subject: Re: breaking up a 200 character field
Author: Gary M McQuown <gary.m.mcquown@FRB.GOV>
Date: 5/2/2000 1:16 PM
The following code (tested) will give you what you asked for.
data a;
x = "You can use the length statement to determine how many variables to create
as well as to determine where to end your substring function";
run;
data b;
set a;
if length(x) <= 50 then
do;
var1 = substr(x,1,length(x));
end; else if 50 < length(x) <=100 then
do;
var1 = substr(x,1,50);
var2= substr(x,51,length(x) -50);
end; else if 100 < length(x) <= 150 then
do;
var1 = substr(x,1,50);
var2= substr(x,51,50);
var3= substr(x,101,length(x)-100);
end; else
do;
var1 = substr(x,1,50);
var2= substr(x,51,50);
var3 = substr(x,101,50);
var4= substr(x,151,length(x)-100);
end;
proc print data=b;
var var: ;
run;
Enjoy,
Gary McQuown
gary-mcquown@sas-econ.com
"K. Patel" <Kunal.Patel@COVANCE.COM> on 05/02/2000 12:26:43 PM
Please respond to Kunal.Patel@COVANCE.COM
To: SAS-L@LISTSERV.UGA.EDU
cc: (bcc: Gary M McQuown/IRM/FRBOG/US)
Subject breaking up a 200 character field
:
I need advice on how to break up a 200 character field into 4 records of 50
characters each.
If there are only 75 characters in the field, then the field will only be
broken into 2 records.
example
center patient symptom
100 1 about 150 characters of data will make
up this field xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
and change into:
center patient symptom
100 1 first 50 +/- characters (don't want to
split a word)
100 1 next 50
100 1 next 50
Any help would be appreciated.
|