【问题标题】:SAS: dataset name Remove the date and replace with the current dateSAS:数据集名称删除日期并替换为当前日期
【发布时间】:2023-03-29 08:00:01
【问题描述】:

我目前有一个宏,可以将我的数据集从一个分支移动到另一个分支。在每个动作中,日期都会更新。但是,我在输入新日期之前无法自动删除旧日期,有什么建议吗?

代码是:

%Macro Merge_Branch(Branch = , Filename = , Library = );

    %Let Timestamp = %sysfunc(putn(%sysfunc(date()),yymmddn8.));

    %if &Branch. = Latest_Commit %then %do;

        Data LC._&Timestamp._&Filename.;
        set &Library..&Filename.;
        run;

    %end;

    %else %if &Branch. = Staging %then %do;

        %Let Filename = _20180909_Financial_Input;
        %Let Filename_temp = %scan(&Filename.,2,'_');
                %Let Date_String = %scan(&Filename.,1,'_');
                /* this is the section where I get stuck the dash is a subtraction i.e. I want to remove the date and just have the string*/
        %Let Filename_Stg = &Filename_temp - &Date_String;

        Data Stg._&Timestamp._&Filename_Stg.;
        set LC.&Filename.;
        run;

    %end;

%mend;

Input data can be made like this

data LC._20180909_Financial_Input;
var var1;
datalines;
1
1
1
1
;
run;

%Macro Merge_Branch(Branch = Staging , Filename = Financial_Input, Library = LC );

/*Note, in this macro the library is not important because it will always move from LC to STG*/

【问题讨论】:

    标签: datetime sas sas-macro sas-studio


    【解决方案1】:

    您的新文件名正在解析。

    Data Stg._20181009_Financial - 20180909;
    

    这不是 SASNAME。

    【讨论】:

    • 我的初衷是显示我希望从_20180909_Financial中减去20180909。由于我的贴错标签等造成的混乱
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-03
    • 2010-11-06
    相关资源
    最近更新 更多