BookmarkSubscribeRSS Feed
mnjtrana
Pyrite | Level 9

I need helpnin a filename statement in sas.. I am using filename statement to read a file using filename statement with wildcards. Code... Filename `/dso/dsocln/hhhw/pers*.dat; However it can b poasible tht many file with same name so we want to.output the file name in sas output file. How to do.tbis? @ Alsi can we check d existence of the file matching the above naming pattern? need urgent help


Cheers from India!

Manjeet
3 REPLIES 3
PGStats
Opal | Level 21

C FILENAME=myFile optn in INFILE stmt.

PG
mnjtrana
Pyrite | Level 9

Hi,

I am using filename statement to read a file using filename statement with wildcards. However it can be possible tht many file with same name so we want to.output the file name in sas output/list file. How to do this? Also can we check d existence of a file matching the naming pattern?

The Filename=variable doesn't provide any option to print the input file name in sas output/list file.

Can you please elaborate?

Here is the sample code:

FILENAME PUA  "/dso/dsocln/&srce./el/out/p_pers_uug*_F201201_*.txt" ;

data PERS ;  

   retain

    PSTYRMO   "201201";

   infile PUA  recfm=v  lrecl=413   truncover ;

   input

     @1  BLOCK    $char387. 

      ;

run ;


Cheers from India!

Manjeet
Haikuo
Onyx | Level 15

Hi,

Personally I prefer to using 'pipe' plus 'filevar=' to tackle the problems like this. For infile statement and wildcard, please refer to this papter:

http://www2.sas.com/proceedings/forum2008/166-2008.pdf

and go to the section:  

"ACCESSING FILE NAMES WITH ‘WILD CARDS’

HTH,

Haikuo

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 687 views
  • 0 likes
  • 3 in conversation