*run each week;
PROC SQL;
create table POLICY_VINTAGE_WEEKLY as
select distinct
POLICY_VINTAGE
,count(NRB) as Count,
today() as Run_Date format=weeku.
from PolisyEnd
where POLIS ="A"
group by
POLICY_VINTAGE
;
Quit;
proc append base=policy_vintage data=policy_vintage_weekly;
run;
Consider instead adding rows and a column to identify each week.
If you really want a wide structure then take your policy_vintage and transpose it as needed for reports.
General principal -> It's easier and faster to add rows to tables, than it is columns. It also takes up less space.
@Gieorgie wrote:
I would like that every time I run the code, the POLICY_VINTAGE dataset would add count (NRB) result from processing as another column called eg Week2 and next week3. Is there any additional feature in SAS for that?
PROC SQL;
create table POLICY_VINTAGE_WEEKLY as
select distinct
POLICY_VINTAGE
,count(NRB) as Week <----- here so that week has a consecutive number, e.g. once week1, then week2
from PolisyEnd
where POLIS ="A"
group by
POLICY_VINTAGE
;
Quit;
data POLICY_VINTAGE ;
set _work.POLICY_VINTAGE
;
run;