BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
lslockle_dat
Calcite | Level 5

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.

 

art297
Opal | Level 21

@lslockle_dat: You will get a much better response if you create a separate thread for your question.

 

Art, CEO, AnalystFinder.com

 

NiyiAwe1
Fluorite | Level 6

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);		   			

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
  • 17 replies
  • 13562 views
  • 9 likes
  • 8 in conversation