SAS data step view and data wrap in a macro for loop

后端 未结 3 1435
挽巷
挽巷 2021-01-28 00:30

For a university research project I am retrieving data from WRDS via SAS and am relatively new to SAS. I am trying to retrieve data in a specific interval provided by WRDS which

3条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-28 00:59

    No idea what your error is but these lines in your macro look problematic.

    First:

    %symdel stock taq_ds filename start_time interval_seconds; */
    %let stock = "COP";     
    %let taq_ds=taq.&tables:;   
    %let filename = &tables._&stock; 
    data  _v_&tables / view=_v_&tables;
    

    What is the purpose of the %SYMDEL? You probably just want to make some %LOCAL macro variables instead. They will then disappear when the macro ends. So no need to delete them. If you need to set them to empty, so inside a %do loop, then just use %let statements.

    Also do you really want to start a statement style comment at the end of the first line? Since the next three lines are all macro statements I think the * will comment up to the semi-colon at the end of the data statement.

    Second:

    DM 'log; file "/home/ &filename.log" replace'; 
    DM "log; clear; ";                                          
    

    Why are you using DM commands? That can only work if you are actually still running SAS using Display Manager.

    What are you trying to do here? If you want to write the log to a separate location then redirect BEFORE hand using

    proc printto log="filename" new; run;
    

    then close it afterwards.

    proc printto log=log; run;
    

提交回复
热议问题