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 (June 1999, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 16 Jun 1999 08:53:58 -0700
Reply-To:     "Terjeson, Mark" <TERJEMW@DSHS.WA.GOV>
Sender:       "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From:         "Terjeson, Mark" <TERJEMW@DSHS.WA.GOV>
Subject:      Re: All files in the directory (SCL functions solution?)
Comments: To: Victor Kamensky <kamensky@AECOM.YU.EDU>,
          SAS-L <sas-l@listserv.uga.edu>
Content-Type: text/plain

PS: you may want to UPCASE() both sides of the 'txt.' test to catch everything.

if upcase(substr(reverse(trim(fname)),1,4)) eq 'TXT.' then output;

> Mark Terjeson > Washington State Department of Social and Health Services > Division of Research and Data Analysis (RDA) > (360) 902-0741 > (360) 902-0705 fax > terjemw@dshs.wa.gov > > > > -----Original Message----- > From: Terjeson, Mark > Sent: Wednesday, June 16, 1999 8:37 AM > To: 'Victor Kamensky'; 'SAS-L' > Subject: RE: All files in the directory (SCL functions solution?) > > Hi Victor, > Here's one way that doesn't use X or CALL SYSTEM. > > > * listing a directory ; > * keeping only .txt names ; > data files(drop=i numsel dirid rc); > rc=filename('dir','c:\temp\'); > dirid=dopen('dir'); > numsel=dnum(dirid); > do i=1 to numsel; > fname=dread(dirid,i); > if fname not in ('.','..') then > do; > if substr(reverse(trim(fname)),1,4) eq 'txt.' then output; > end; > end; > rc=dclose(dirid); > run; > > proc print data=files; > run; > > > Hope this helps, > Mark Terjeson > Washington State Department of Social and Health Services > Division of Research and Data Analysis (RDA) > (360) 902-0741 > (360) 902-0705 fax > terjemw@dshs.wa.gov > > > > > > > -----Original Message----- > From: Victor Kamensky [SMTP:kamensky@AECOM.YU.EDU] > Sent: Wednesday, June 16, 1999 7:20 AM > To: SAS-L@UGA.CC.UGA.EDU > Subject: All files in the directory (SCL functions solution?) > > Hi,SAS-L-ers! > I want to create a SAS data set > with names of all files in in a directory (PAT) > with extension TXT. > I use SAS 6.12 on Windows 95. > My solution is: > > options noxwait; > data _null_; > call system ('dir pat > pat.lst') ; run; > > data plist(keep=patname); > infile 'pat.lst' missover length=l; > length line $ 80 patname $ 8; > input line $varying. l ; > ind= index(upcase(line),'.TXT'); > if ind > 0; > patname=scan(line,1); > run; > It works, but I have 2 problems: > 1. I tried to use > x('dir pat > pat.lst') ; > instead of call system, but the file was not > created. > 2.I would prefer not to go to the system at all. > I tried to use pathname function: > > filename pats 'c:\pat\*.txt' > data _null_; > length patname $ 200; > patname=pathname ('pats'); > put patname=; > run; > > But it does not work: > patname keeps all names of the files, > and summary length of all names could be > more than maximal length of a character > variable (200 now ). > Any ideas? > Victor Kamensky > Programmer > Albert Einstein College of Medicine


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