全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
9762 7
2014-08-05
请问如何提取变量的最后一个观测值,然后我想用%let 将这个值赋给某个宏变量,这个应该怎么实现?谢谢
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2014-8-6 06:59:43
Here is one.

data _null_;
   call symputx('lastobs',lastobs);
   stop;
   set sashelp.class nobs=lastobs;
run;

%put >>>&lastobs<<<;
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2014-8-6 08:49:19
bob的回复应该和lz的要求不太一致,改了下

data t;
   set sashelp.class nobs=lastobs;
   if _N_ EQ lastobs then call symputx('lastage',Age);
run;

%put >>>&lastage<<<;

另外问下bob兄,stop好像加不加都行,有什么具体的作用吗?谢谢!
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2014-8-6 09:03:19
playmore 发表于 2014-8-6 08:49
bob的回复应该和lz的要求不太一致,改了下

data t;
Stop statement will stop SAS internal loops.

The point here is to access last and only last obs.

data _null_;
   point=lastobs;
   set sashelp.class nobs=lastobs point=point;
   call symputx('lastage',Age);
   stop;
run;

%put >>>&lastage<<<;
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2014-8-6 09:03:26
playmore 发表于 2014-8-6 08:49
bob的回复应该和lz的要求不太一致,改了下

data t;
Stop statement will stop SAS internal loops.

The point here is to access last and only last obs.

data _null_;
   point=lastobs;
   set sashelp.class nobs=lastobs point=point;
   call symputx('lastage',Age);
   stop;
run;

%put >>>&lastage<<<;
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2014-8-6 09:06:06
bobguy 发表于 2014-8-6 06:59
Here is one.

data _null_;
I thought the original request is to pass # of obs to a macro variable.

The nobs of a data set is available at compiling time.
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群