- proc sql noprint;
- create table sale as
- select
- month as date format=date9. label="Sale Date",
- country as shop label="Shop",
- division as item_name label="Item Name (Classification Variable)",
- sum(actual) as sale_amount label="Sale Amount"
- from sashelp.prdsale
- group by month, country, division
- order by country, division, month
- ;
- quit;
- proc sgpanel data=sale;
- PANELBY item_name /ONEPANEL COLUMNS=1;
- series x=date y=sale_amount /group=shop;
- run;
如果有多个分类变量, 可以把分类变量存在一个sas macro里, 用空格分隔
%let loopvar=item_name1 item_name2 item_name3;
完整的循环程序如下:
- %macro loop_plot;
- %let loopvar=item_name1 item_name2 item_name3;
- %let loopn=%sysfunc(countw(&loopvar));
- %do i=1 %to &loopn.;
- proc sgpanel data=sale;
- PANELBY %scan(&loopvar.,&i) /ONEPANEL COLUMNS=1;
- series x=date y=sale_amount /group=shop;
- run;
- %end;
- %mend;
- %loop_plot;


雷达卡




初学的痛苦。
京公网安备 11010802022788号







