아주 오랜만에 글쓰기 하네요.
가끔 제목과 관련된 작업이 필요해서 간단히 만들어 사용하고 있는 프로그램입니다.
->directory, filetype만 지정해 주면 파일이름이 데이터로 저장됩니다.
참조하세요!!!
/*LIBNAME _MYjob "D:\_작업창고\_1분석작업창고\data" ;*/
%LET LIB = _MYJOB ;
/* 파일이름을 가져올 directory 지정 */
%LET FilePath = %STR(C:\Program Files (x86)\SAS\JMP\12\Samples\Data\Time Series) ;
/* 가져올 파일의 형식 지정 */
%let FileType = %UPCASE(jmp) ; /* 형식 미지정 시에는 => %UPCASE() ; */
%macro m_GetFile (FilePath) ;
data fileList;
length FileName $ 100 ; /* 파일명 길이 할당*/
rc=filename("myDir","&FilePath");
if rc=0 then do;
* 디렉토리 Open;
did=dopen("myDir");
if did > 0 then do;
* 디렉토리의 멤버(파일) 갯수 반환;
memcount=dnum(did);
do i=1 to memcount;
* 디렉터리의 멤버(파일) 이름 반환;
FileName=dread(did,i);
output;
end;
rc=dclose(did);
end;
rc=filename('myDir',' ');
end;
keep FileName ;
run;
/* 특정 형식 파일 이름명 한정 */
data fileList_Out ;
format no ;
set fileList;
extension = scan(FileName,-1,".") ;
if FileName = extension then extension = "" ;
if "&FileType" ="" then goto skip_where ;
where UPCASE(FileName) contains "&FileType" ;
skip_where:
no = _n_ ;
call symput("no_file_total" , _n_) ;
run;
%put 전체 파일갯수 : &no_file_total ;
%mend ;
%m_GetFile (&FilePath ) ;
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.