Macros 用于打印多个报告的SAS宏
我有一个如下所示的数据集:Macros 用于打印多个报告的SAS宏,macros,sas,Macros,Sas,我有一个如下所示的数据集: data have; input name $ class $ time score; cards; chewbacca wookie 1 97 chewbacca wookie 2 100 chewbacca wookie 3 95 saruman wizard 1 79 saruman wizard 2 85 saruman wizard 3 40 gandalf wizard 1 22 gandalf wizard 2 50 gandalf wizar
data have;
input name $ class $ time score;
cards;
chewbacca wookie 1 97
chewbacca wookie 2 100
chewbacca wookie 3 95
saruman wizard 1 79
saruman wizard 2 85
saruman wizard 3 40
gandalf wizard 1 22
gandalf wizard 2 50
gandalf wizard 3 87
bieber canadian 1 50
bieber canadian 2 45
bieber canadian 3 10
;
run;
我正在创建一个程序,它有两个功能:
1.打印每个不同类的数据
2.为每个名称创建散点图x=时间y=分数
执行下面的代码将说明我想要的输出:
data chewbacca saruman gandalf bieber;
set have;
if name='chewbacca' then output chewbacca;
else if name='saruman' then output saruman;
else if name='gandalf' then output gandalf;
else if name='bieber' then output bieber;
run;
title 'Report for wookie';
proc print data=have;
where class='wookie';
run;
title 'Plot Chewbacca';
proc sgplot data=chewbacca;
scatter x=time y=score;
run;
title 'Report for wizard';
proc print data=have;
where class='wizard';
run;
title 'Plot Saruman';
proc sgplot data=saruman;
scatter x=time y=score;
run;
title 'Plot Gandalf';
proc sgplot data=gandalf;
scatter x=time y=score;
run;
title 'Report for canadian';
proc print data=have;
where class='canadian';
run;
title 'Plot Bieber';
proc sgplot data=bieber;
scatter x=time y=score;
run;
理想情况下,我想自动化这个。我一直在尝试设置这个,但我遗漏了一些东西。以下是我的尝试:
proc sql;
select count(distinct name) into :numname
from have;
%let numname=&numname;
select distinct name into :name1 - :name&numname
from have;
select count(distinct class) into :numclass
from have;
%let numclass=&numclass;
select distinct class into :class1 - :class&numclass
from have;
quit;
%macro printit;
%do i = 1 %to &numclass;
title 'Report for &&class&i';
proc print data=have;
where class=&&class&i;
run;
/*insert sgplot here*/
%end;
%mend;
%printit;
请帮忙。无法对语法进行排序
谢谢。我看到4期
标题“i类报告”代码>
其中class=“&&class&i”代码>
SGPLOT
proc sgplot data=have(其中=(name=“&&name&i”)代码>
SGPANEL
和/或SGRENDER
。您可以在一次调用中生成所有图表。我看到了4个问题
标题“i类报告”代码>
其中class=“&&class&i”代码>
SGPLOT
proc sgplot data=have(其中=(name=“&&name&i”)代码>
编辑:同时查看
SGPANEL
和/或SGRENDER
。您可以在一次调用中生成所有图表。打印过程和大多数ODS过程都支持分组处理,这可能会简单得多,并根据您的需要节省大量时间
proc sort data=have; by class;
proc print data=have;
by class;
run;
及
print
过程和大多数ODS过程都支持分组处理,这可能会简单得多,并根据需要节省大量时间
proc sort data=have; by class;
proc print data=have;
by class;
run;
及
你能告诉我们你得到的错误吗?你能告诉我们你得到的错误吗?谢谢@DomPazz。这绝对是我想要的。我也会研究一下你建议的其他程序,看看这些程序是否更适合这个程序。谢谢@DomPazz。这绝对是我想要的。我也会研究你建议的其他程序,看看这些程序是否更适合这个程序。