关于SAS变量的默认初始化值的问题

关于SAS变量的默认初始化值的问题,sas,Sas,我对以下SAS代码有两个问题: %let crsnum=3; data revenue; set sasuser.all end=final; where course_number=&crsnum; total+1; if paid=’Y’ then paidup+1; if final then do; call symput(’numpaid’,paidup); call symput(’numstu’,total); call symput(’crsname’,

我对以下SAS代码有两个问题:

%let crsnum=3;
data revenue;
set sasuser.all end=final;
where course_number=&crsnum;
total+1;
if paid=’Y’ then paidup+1;
if final then do;
   call symput(’numpaid’,paidup);
   call symput(’numstu’,total);
   call symput(’crsname’,course_title);
end;
run;
proc print data=revenue noobs;
   var student_name student_company paid;
   title "Fee Status for &crsname (#&crsnum)";
   footnote "Note: &numpaid Paid out of &numstu Students";
run;
第一个问题,在第5行,它有

if paid=’Y’ then paidup+1;
“paidup”在这里应该是一个变量。 在我看来,SAS将“paidup”的默认初始值设置为0。这是真的吗

第二个问题,在

title "Fee Status for &crsname (#&crsnum)";

#&crsnum如何工作?或者#here的功能是什么?

第一个问题:是的,SAS就是这么做的-它用0初始化变量,并在数据集循环中“保留”变量的值。(除非源数据中已经存在变量paidup,在您的情况下为sasuser.all)

第二个问题:在您发布的代码中,
#
没有什么特别之处:它将作为文本显示在标题中
&crsnum
的解析值之前。因此,如果&crsname为Blah,&crsnum为3,则标题将为

Blah(#3)的费用状态


但是,当一个
by
组以特定方式包含在标题中时,#可以影响标题-请参阅标题为“将分组信息插入标题”下的文档。

第一个问题:是的,这就是SAS所做的-它已使用0初始化变量,并在数据集循环中“保留”变量的值。(除非源数据中已经存在变量paidup,在您的情况下为sasuser.all)

第二个问题:在您发布的代码中,
#
没有什么特别之处:它将作为文本显示在标题中
&crsnum
的解析值之前。因此,如果&crsname为Blah,&crsnum为3,则标题将为

Blah(#3)的费用状态

但是,当
by
组以特定方式包含在标题中时,#可以影响标题-请参阅标题“将按组信息插入标题”下的文档