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

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

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