楼主: ike982008
9343 7

SAS选取变量最后一个观测值 [推广有奖]

  • 0关注
  • 0粉丝

硕士生

64%

还不是VIP/贵宾

-

威望
0
论坛币
646 个
通用积分
1.5400
学术水平
2 点
热心指数
2 点
信用等级
0 点
经验
6198 点
帖子
124
精华
0
在线时间
205 小时
注册时间
2012-5-14
最后登录
2021-10-29

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
请问如何提取变量的最后一个观测值,然后我想用%let 将这个值赋给某个宏变量,这个应该怎么实现?谢谢
二维码

扫码加我 拉你入群

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

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

关键词:最后一个 观测值 如何提取 let 如何

本帖被以下文库推荐

沙发
bobguy 发表于 2014-8-6 06:59:43 |只看作者 |坛友微信交流群
Here is one.

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

%put >>>&lastobs<<<;

使用道具

藤椅
playmore 发表于 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好像加不加都行,有什么具体的作用吗?谢谢!

使用道具

板凳
bobguy 发表于 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<<<;

使用道具

报纸
bobguy 发表于 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<<<;

使用道具

地板
bobguy 发表于 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.

使用道具

7
playmore 发表于 2014-8-6 09:07:25 |只看作者 |坛友微信交流群
bobguy 发表于 2014-8-6 09:03
Stop statement will stop SAS internal loops.

The point here is to access last and only last obs ...
多谢,明白了
那你这段代码应该比我那个快多了

使用道具

8
夙o翎 发表于 2014-12-21 19:21:46 |只看作者 |坛友微信交流群
data c;
   point=lastobs;
   set b nobs=lastobs point=point;
   call symputx('lastl',l);
   stop;
run;
为什么我这样写就得不到想要的结果呢?

使用道具

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

本版微信群
加好友,备注cda
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-4-30 16:59