* SAS에서 날짜 처리 예제(기타 날짜 처리 참고);
data back;
BASE_DT = put(today(),yymmddn8.);
BASE_BF7D_DT = put(today()-1-7,yymmddn8.);
BASE_BF15D_DT = put(today()-1-15,yymmddn8.);
base_date = "'"||BASE_DT||"'";
DEL_BF15D = "'"||BASE_BF15D_DT||"'";
first_date = "'"||PUT(intnx('MONTH',input(BASE_DT,yymmdd10.),0,'beginning'),yymmddn8.)||"'";
DEL_date = "'"||PUT(intnx('MONTH',input(BASE_DT,yymmdd10.),-5,'beginning'),yymmddn8.)||"'";
call symput('BASE_DT',BASE_DT);
call symput('base_date',base_date);
call symput('first_date',first_date);
call symput('BASE_BF7D_DT',BASE_BF7D_DT);
call symput('DEL_BF15D',DEL_BF15D);
call symput('DEL_date',DEL_date);
run;
%put &BASE_DT;
%put &base_date;
%put &first_date;
%put &BASE_BF7D_DT;
%PUT &DEL_BF15D;
%PUT &DEL_date;
* I:\SAS Temporary Files\back_20191217.txt 파일 읽어오기;
* back_20191217.txt 샘플데이터;
* 1 2 3
* 4 5 6
* 7 8 9
* 참고 예제 : http://support.sas.com/kb/24/577.html;
* 파일이 저장된 폴더 위치와 해당 파일 지정;
%let testfile = %sysfunc(catt(I:\SAS Temporary Files\,back_,&BASE_DT,.txt));
%put &testfile=;
* 해당 파일이 존재하는 경우 파일을 import;
%macro findit;
%if %sysfunc(fileexist("&testfile")) %then %do;
data one;
infile "&testfile";
input a b c;
run;
%end;
%else %put The file &testfile does not exist. ;
%mend;
/* invoke the macro */
%findit;
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.