Date: Thu, 12 Nov 2009 15:56:34 -0500
Reply-To: Arthur Tabachneck <art297@NETSCAPE.NET>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Arthur Tabachneck <art297@NETSCAPE.NET>
Subject: Re: Separating an ID from a Variable String
Craig,
While I'm sure that you already have your needed solution, it was pointed
out to me (offline .. thanks again Howard) that that I had engaged in a
bit of unnecessary over-engineering.
The following does the same thing a lot more easily:
data Example;
input FileName $ 1-38;
FinalID =scan(filename,-2,'-');
datalines;
Assessment1-Sample-1234-1.txt
Assessment2-Whatever-12-3.edat
MakingThingsDifficult-Booo-567-2.txt
;
Art
---------
>Craig,
>
>One more suggestion: since your filenames may have extra hyphens, you
could
>always use a scan on the reverse of the filename. E.g.,
>
>data Example;
> input FileName $ 1-38;
> FinalID =reverse(scan(reverse(filename),2,'-'));
> datalines;
>Assessment1-Sample-1234-1.txt
>Assessment2-Whatever-12-3.edat
>MakingThingsDifficult-Booo-567-2.txt
>;
>
>HTH,
>Art
>---------
>On Tue, 10 Nov 2009 14:59:09 -0600, Craig Johnson <cjohns38@GMAIL.COM>
>wrote:
>
>>Hi Joe,
>>
>>Thanks for your quick response. It looks like you had a similar idea as
>>Arthur and took it the extra step of conpensating for the number of
>>character separators like I posted after Arthur's suggestion. I ran the
>>code and it worked on the 464 files we have so it looks very promising.
>>Thanks to both of you for your help.
|