LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (May 2000, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 2 May 2000 13:16:51 -0400
Reply-To:     Gary M McQuown <gary.m.mcquown@FRB.GOV>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Gary M McQuown <gary.m.mcquown@FRB.GOV>
Subject:      Re: breaking up a 200 character field
Content-type: text/plain; charset=us-ascii

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.


Back to: Top of message | Previous page | Main SAS-L page