How can this me amended to look for files that are on a server? Specifically I am getting a "..not enough arguments..." error in the 'dopen' function and I think it's because my &filref is not local, it's a different server. I created the connection with the "options comamid=tcp remote=sascnct9" but i think the issue is the parameter '&dir'. I don't know how to pass in files that aren't local.
@lslockle_dat: You will get a much better response if you create a separate thread for your question.
Art, CEO, AnalystFinder.com
This Macro should help too:
/*MACRO TO GET ALL FILE NAMES AND DETAILS WITHIN A DIRECTORY*/
%MACRO GET_FILE_NAMES(FILE_DIR ,COMMON_FILE_NAME ,FILE_FORMAT ,DATA_OUT);
FILENAME LS PIPE "dir &FILE_DIR.&COMMON_FILE_NAME.*.&FILE_FORMAT.";
DATA FILE_NAMES (KEEP=LIST_FILE);
INFILE LS PAD TRUNCOVER EXPANDTABS ;
INPUT FILE_NAMES $10000.;
LIST_FILE = COMPRESS('"'||FILE_NAMES||'"');
RUN;
PROC SQL; SELECT LIST_FILE AS LIST_FILE INTO: LIST_FILE_1 - FROM FILE_NAMES; QUIT;
PROC SQL; SELECT COUNT(*) AS NUM_OF_SEARCHES INTO: NUM_OF_SEARCHES FROM FILE_NAMES; QUIT;
%DO Z = 1 %TO &NUM_OF_SEARCHES.;
DATA RAW_WANT;
FILENAME LISA &&LIST_FILE_&Z..;
INFILE LISA TRUNCOVER ;
FORMAT FILE_NAME $20000.;
FILE_NAME = &&LIST_FILE_&Z..;
FLIE_SIZE = FINFO(FOPEN('LISA') ,'FILE SIZE (BYTES)');
FORMAT MOD_DATE DATETIME.;
MOD_DATE = INPUT(FINFO(FOPEN('LISA') ,'LAST MODIFIED'), DATETIME.);
RIGHTS = FINFO(FOPEN('LISA') ,'ACCESS PERMISSION');
OWNER = FINFO(FOPEN('LISA') ,'OWNER NAME');
RUN;
PROC APPEND DATA = RAW_WANT BASE = WANT_1 FORCE; RUN;
%END;
DATA &DATA_OUT.; SET WANT_1; RUN;
PROC DATASETS; DELETE WANT_1 RAW_WANT FILE_NAMES; RUN;
%MEND GET_FILE_NAMES;
/*INPUT PARAMETERS HERE*/
%GET_FILE_NAMES (FILE_DIR = \Users\abc\Desktop\ /* SPECIFY THE DIRECTORY LOCATION HERE*/
, COMMON_FILE_NAME = HAVE_NAME /* FILE COMMON NAME, YOU CAN PUT "*" HERE TO SELECT ALL FILE NAMES*/
, FILE_FORMAT = txt /* FILE FORMAT, YOU CAN PUT "*" HERE TO SELECT ALL FILE FORMATS WITHIN THE DIRECTORY*/
, DATA_OUT = WANT);
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: