日期作为变量名
我想使用日期作为变量名。我知道我需要在前面附加一个字符,而且这不是存储数据的好方法(这纯粹是为了报告美观)。我尝试过 %eval()
但无法解决。
%let var_date = '_'||today();
data date;
%eval(&var_date) = .;
run;
我希望变量名称为 _02JUN2011
。感谢您的任何帮助。
I'd like to use the date as a variable name. I understand I'll need to append a character to the front and also that it's not a good way to store data (it's purely for report aesthetics). I've tried %eval()
but can't solve it.
%let var_date = '_'||today();
data date;
%eval(&var_date) = .;
run;
I'd like the variable name to be _02JUN2011
. Thanks for any help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我认为您不想采取这种方法。您应该在 PROC REPORT(或任何其他报告 PROC)中使用标签,或者动态地旋转数据。也许如果您描述您所获得的数据和您想要的输出,这里的人们将能够帮助找到合适的解决方案。
不过,为了您的启发,以下代码可以完成您在帖子中尝试执行的操作:
I don't think you want to take this approach. You should use labels in PROC REPORT (or any other reporting PROC), or pivot your data dynamically instead. Perhaps if you describe the data you've got and the output you want, people here will be able to help find an appropriate solution.
For your edification though, the following code does what you're trying to do in your post:
这就是我正在寻找的。这可以维护吗?
This does what I'm looking for. Is this maintainable?
你真的想使用哈希 - 这不是可维护的代码..
You really want to use a hash - this is not maintainable code..