[英]How to define Current Year in SAS
我正在嘗試做一個非常簡單的SAS計算,例如Age = current_year-born_year。
如何設定本年度? 我嘗試了current_year = 2018; 但是SAS不喜歡這個答案?
我需要知道如何將當前年份設置為2018年。
data merged_bike;
merge all_clean_data (in=a) boroughs(in=b);
by station_id;
if a and b;
run;
Current_year =2018;
Age= Current_year - birth_year;
if Age <29 then age_group ='0-29';
else if Age > 30 and age<40 then age_group= '30-39';
else if Age>40 and age<50 then age_group='40-49';
else if Age>50 and age<60 then age_group='50-59';
else if Age>60 and age<70 then age_group='60-69';
run;
您不能在數據步驟之外有賦值語句。 刪除多余的run;
過早結束數據步驟定義的語句。
或創建第二個數據步驟以讀回數據並運行年齡計算。
如果想要今天的年份,則可以使用date()
函數(或其別名today()
),然后使用year()
函數提取年份。
current_year = year(date());
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.