LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (November 2009, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Tue, 10 Nov 2009 15:40:29 -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
Content-Type:   text/plain; charset=ISO-8859-1

Craig,

Couldn't you just use the scan function? e.g.,:

data Example; input FileName $ 1-38; FinalID =scan(filename,3,'-'); datalines; Assessment1-Sample-1234-1.txt Assessment2-Whatever-12-3.edat MakingThingsDifficult-Booo-567-2.txt ;

Art --------- On Tue, 10 Nov 2009 14:29:49 -0600, Craig Johnson <cjohns38@GMAIL.COM> wrote:

>I�m reading in directory contents using a dirlistwin macro (available here: >http://support.sas.com/kb/24/addl/fusion24820_1_dirlistwin.sas.txt) so I can >compare the files in a directory vs. what a database says we should have. Each >file is named in the basic following format Assessment-Whatever-#####- #.txt >or Assessment-Part2-##-1.txt. What I�d like to be able to do is split the >string at the -###-#.txt so I end up with the first the digits between the >��s. Below is an example of what I�m working with and the final outcome I�m >looking for. Any help on how to get there would be greatly appreciated. > > > >******************** >Sample Data Set > >********************; > > > >*data* Example; > > input FileName $*1*-*38* /*read from the Macro*/ > > FinalID *39*-*44*/*The Final ID I need to match with the DB*/; > >datalines; > >Assessment1-Sample-1234-1.txt 1234 > >Assessment2-Whatever-12-3.edat 12 > >MakingThingsDifficult-Booo-567-2.txt 567 > >; > >*run*;


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