楼主: pinggu2688
4475 3

[原创博文] 求助代码所在行数的宏变量 [推广有奖]

  • 2关注
  • 0粉丝

博士生

6%

还不是VIP/贵宾

-

威望
0
论坛币
40 个
通用积分
40.2335
学术水平
1 点
热心指数
3 点
信用等级
1 点
经验
3113 点
帖子
166
精华
0
在线时间
103 小时
注册时间
2009-11-12
最后登录
2024-8-28

楼主
pinggu2688 发表于 2012-1-15 03:48:04 |AI写论文
30论坛币
请问有没有SAS自动宏变量记录SAS代码所在的行数?
num是用来显示代码行数的命令,有没有什么宏变量来记录这个数值?
谢谢

关键词:sas代码 请问有没有 有没有 NUM 记录

沙发
jingju11 发表于 2012-1-15 05:32:36
very interesting question. if you have the answer, please kindly let me know. that should be a high-level question.

jingju

藤椅
maidenhan 发表于 2012-1-15 10:44:40
I don't know the direct way to get the code lines number, but I wish my codes could help.

data test02;
        format text $30000.;
        infile "D:\test.sas" dlm='0a'x;
        input text $ ;
run;
proc sql noprint;
        select count(*) into:code_line_number
        from test02;
quit;
%put &code_line_number.;



And I created the "test.sas" in my D disc, with its detail in the following.
data test01;
        input id ;
cards;
1
2
3
4
5
6
7
8
9
0
;run;

板凳
pinggu2688 发表于 2012-1-23 03:40:23
maidenhan 发表于 2012-1-15 10:44
I don't know the direct way to get the code lines number, but I wish my codes could help.

data te ...
谢谢您的回复,您的代码是把另一个SAS代码("test.sas")当作文本读入,然后计算其行数,但是那段代码并不是当前正在运行的代码(使用sql语句的那段)。
我需要的是“当前正运行的代码”中的的行数,也就是需要SAS某自动宏变量能产生,我相信一定有这个功能,但是我不知道如何能用什么方法或者函数返回这个值,也许需要使用SAS底层的命令。

我打个比方,在您的代码中,Sql语句可能是您在一大段代码中的一小段,我如何知道其中“from test02”这段是第几行?
我产生这个问题的用途是为了调试代码的时候使用某种宏命令加在代码中,然后运行程序后就可以在log中使用put显示对应的是SAS里哪行代码。编辑上千行的代码会很方便查找log对应SAS哪行有问题。
谢谢。

继续求助高手。

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2026-1-7 04:30