简体   繁体   English

如何在SAS宏中创建字符变量?

[英]How can I create a character variable in a SAS macro?

I am trying to create two variables, one for year, one for month. 我正在尝试创建两个变量,一个用于一年,一个用于一个月。 The year variable is numeric so the code creates it without problem. 年份变量是数字,因此代码可以毫无问题地创建它。 However, the month variable is character and the code sees it as blank. 但是,month变量是字符,代码将其视为空白。 How can I fix This? 我怎样才能解决这个问题? Thanks! 谢谢!

data sourceh.combined&month.&year.;
set sourceh.count;
ratio=count/total;
month=&month.;
year= &year.;
run;

Your code would resolve to : 您的代码将解析为:

month = December;

That would be treating the macro variable month as a variable name. 那就是将宏变量month视为变量名。 To create it as a character variable, you should include it in quotation marks, double quotes so the macro variable resolves. 要将其创建为字符变量,应将其包含在引号,双引号中,以便宏变量解析。

month = "&month";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM