1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

SAS言語備忘録_SAS日付で過去から未来へループ

Last updated at Posted at 2020-03-03

#ファイル名に日付が入ってるデータセットを扱う
SAS言語のマクロ変数に開始日と終了日をYYYYMMDD形式で持たせてSAS日付に変換してひたすらループさせるだけ。

Sample.sas
%let START=20190715;
%let END=20190810;

%let S_DATE=%sysfunc(inputn(&START.,yymmdd8.));
%let E_DATE=%sysfunc(inputn(&END.,yymmdd8.));

%let ROOP=%eval(&E_DATE.-&S_DATE.);

%put &S_DATE.;
%put &E_DATE.;
%put &ROOP.;

%macro get_roop(ROOP);
	%do i=0 %to %eval(&ROOP.);
		%let T_DATE=%sysfunc(putn(%eval(&S_DATE.+&i.),yymmddn8.));
		%put &T_DATE.;
	%end;
%mend;

%get_roop(&ROOP.);
1
2
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?