> From: Whitworth, William C. (Kit)
> Subject: inserting (not replacing!) characters into strings
> I have eight digit (character format) patient IDs ("PT") (ex:
> that I need to insert hyphens into to give me 28-32-0102. I tried the
> substr function (for the first hyphen only) [substr (PT, 3,
> 1) = "-";], but
> this will replace the original value with a "-" rather than
> inserting the
> hyphen (i.e., it gives "28-00102" instead of "28-300102").
> Any help would
> be greatly appreciated! Hope this was clear.
> From: bruce johnson
> It may not be the most elegant, but it works...
> data temp;
> put _all_;
> PATIENTID=28300102 PATID=28-30-0102 _ERROR_=0 _N_=1
You can also use the New&Improved cat function
the first argument is the delimiter to insert between successive strings
PatId = catx('-',substr(patientid,1,2)
if the PatientId were numeric,
which would be appropriate since it is a PrimaryKey,
then you could use a picture format to do this
RTFM on The Format Procedure, Picture Statement
Ron Fehd the macro maven CDC Atlanta GA USA RJF2 at cdc dot gov