我想每个月自动化sas代码

时间:2017-03-09 14:45:16

标签: sas

我正在计算 12个指标(比较最近12个月每个月的销售额)。每个月我都需要手动操作并随处更改月份。如果有任何方法可以自动化它,那将非常有帮助。我的代码是

proc sql;
create table inter.calls as
select a.district_name, 
       sum(01JAN2016,01FEB2016,01MAR2016)/terr_count as q1_workingdays,
       sum(01APR2016,01JUN2016,01MAY2016)/terr_count as q2_workingdays,
       sum(01AUG2016,01SEP2016,01JUL2016)/terr_count as q3_workingdays,
       sum(01NOV2016,01DEC2016,01OCT2016)/terr_count as q4_workingdays
from inter.calls_made_bymon_reg3 a left join inter.territory_count b
on a.district_name=b.district_name;
quit;

现在当我为JAN2017刷新时,我需要在最近的12个月内从FEB2016更改为JAN2017。每次手动更改代码都很困难。

如果我得到任何帮助,我将非常感激!!

1 个答案:

答案 0 :(得分:0)

很难完全理解你的问题,因为Reeza提到.global main main: SUB SP, SP, #16 @ Create 16 bytes storage LDR R0, .addr_file @ get GPIO Controller addr LDR R1, .flags @ set flag permissions BL open @ call to get file handle STR R0, [SP, #12] @ File handle number LDR R3, [SP, #12] @ Get File handle STR R3, [SP, #0] @ Store file handle on top stack LDR R3, .gpiobase @ get GPIO_Base address STR R3, [SP, #4] @ store on SP+4 MOV R0, #0 @ R0=0 MOV R1, #4096 @ R1=page MOV R2, #3 @ R2=3 MOV R3, #1 @ R3=1 (stdouts) BL mmap @ call libc fct for mmap STR R0, [SP, #16] @ store virtual mem addr LDR R3, [SP, #16] @ get virtual mem addr fctsel: ADD R3, R3, #4 @ add 4 for block 1 (GPFSEL1) LDR R2, [SP, #16] @ get virtual mem addr ADD R2, R2, #16 @ add 4 for block 1 (GPFSEL1) LDR R2, [R2, #0] @ load R2 with value at R2 BIC R2, R2, #0b111<<24 @ Bitwise clear of three bits STR R2, [R3, #0] @ Store result in Register [set input] LDR R3, [SP, #16] @ Get virtual mem address ADD R3, R3, #4 @ Add 4 for block 1 (GPFSEL1) LDR R2, [SP, #16] @ Get virtual mem addr ADD R2, R2, #4 @ add 4 for block 1 (GPFSEL1) LDR R2, [R2, #0] @ Load R2 with value at R2 ORR R2, R2, #1<<24 @ Set bit.... STR R2, [R3, #0] @ ...and make output on: LDR R3, [SP, #16] @ get virt mem addr MOV R4, #1 @ get 1 MOV R2, R4, LSL#18 @ Shift by pin number STR R2, [R3, #0] @ write to memory LDR R0, [SP, #12] @ get file handle BL close @ close file ADD SP, SP, #16 @ restore SP MOV R7, #1 SWI 0 .addr_file: .word .file .flags: .word 1576962 @.gpiobase: .word 0x20200000 @ GPIO_Base for Pi 1 .gpiobase: .word 0x3F200000 @ GPIO_Base for Pi 2 .data .file: .ascii "/dev/mem\000" 函数中的参数无效(名称以数字开头)。

但是,我确实理解不想在整个地方手动更改日期的愿望。您可能会发现以下有用的宏:

sum()

然后你会在你的查询中使用它,如下所示:

%macro prev_month(n);
    %let latest_date = %sysfunc(intnx(month,%sysfunc(inputn(&latest_month.,monyy7.)),-&n.));
    days_%sysfunc(putn(&latest_date.,monyy7.))
%mend prev_month;

希望它有所帮助。