BookmarkSubscribeRSS Feed
s_lassen
Meteorite | Level 14

Sorry, forgot a line in the program, the filename statement:

%let dir=/usr/local/tmp; /* full path of directory with files */
Filename indir "&dir";
data members;
  did=dopen('indir');
  do _n_=1 by 1;
    fname=dread(did,_N_);
    if fname=' ' then leave;
    /* you can also put criteria here, instead of in the next datastep, 
       only LIKE is very nifty and only available with WHERE */
    output;
    end;
  keep fname;
run;

data hcount;
  set members;
  where upcase(fname) like '%.TXT'; /* or whatever criteria you want */
  path=cats("&dir",'/',fname); /* may have to change / to \ for Windows */
  infile dummy filevar=path;
  input;
  count=count(_infile_,'09'x);
  keep fname count;
run;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 15 replies
  • 3813 views
  • 1 like
  • 6 in conversation