楼主: ttklkl
4512 6

[实际应用] 如何提取符合条件的变量? [推广有奖]

  • 1关注
  • 6粉丝

博士生

85%

还不是VIP/贵宾

-

威望
0
论坛币
232 个
通用积分
2.0018
学术水平
11 点
热心指数
11 点
信用等级
8 点
经验
31591 点
帖子
119
精华
0
在线时间
609 小时
注册时间
2009-6-15
最后登录
2021-12-22

楼主
ttklkl 发表于 2011-3-17 15:27:27 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
请教大家一个问题:
我有一个数据集a如下:
data a;
input center $ scrono $ seqno weight height sbp subinit $;
cards;
1 001 1 60 170 140 abc
1 001 2 60 170 145 abc
1 002 1 55 165 137 efg
1 002 2 55 165 141 efg
..............................
;
run;

同时有一个Excel表,共2列
variables   message
center       center number
scrono      patient number
seqno       sequence number
svdat        visit date
vshr         heart rate
weight     weight
height      height
sbp         sbp
....................

现在需要做的是,保留数据集a中的变量,其中保留的这些变量都在Excel表中variables 列出现过,
请教下各位如何实现,谢谢!
二维码

扫码加我 拉你入群

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

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

关键词:如何提取 Variables Variable 请教大家一个问题 sequence 变量 条件

回帖推荐

本帖被以下文库推荐

Stay Hungry. Stay Foolish.

沙发
red2005070313 发表于 2011-3-17 15:43:09
不是很懂楼主的问题,是否可以考虑用EXCEL里的数据筛选功能 1# ttklkl

藤椅
baoaibaobao 发表于 2011-3-17 16:16:07
  1. data a;
  2. input center $ scrono $ seqno weight height sbp subinit $;
  3. cards;
  4. 1 001 1 60 170 140 abc
  5. 1 001 2 60 170 145 abc
  6. 1 002 1 55 165 137 efg
  7. 1 002 2 55 165 141 efg
  8. ;
  9. run;
  10. proc import datafile='E:\aa.xls' out=aa
  11.         dbms=excel2003 replace;
  12.         scantext=yes;
  13.         getnames=yes;
  14. run;
  15. proc sql noprint;
  16.         select b.name into:name separated by ' '
  17.                 from aa as a inner join
  18.                         (select name from dictionary.columns
  19.                                 where libname='WORK' and memname='A') as b
  20.                 on a.variables=b.name;
  21. quit;
  22. %put &name;
  23. data a;
  24.         set a;
  25.         keep &name;
  26. run;

  27.                
复制代码
已有 1 人评分经验 论坛币 收起 理由
bakoll + 3 + 3 精彩帖子

总评分: 经验 + 3  论坛币 + 3   查看全部评分

板凳
ttklkl 发表于 2011-3-17 17:22:41
3# baoaibaobao

Hi,baoaibaobao ,  运行有错误。
Stay Hungry. Stay Foolish.

报纸
baoaibaobao 发表于 2011-3-17 20:08:36
ttklkl 发表于 2011-3-17 17:22
3# baoaibaobao

Hi,baoaibaobao ,  运行有错误。
我在9.2运行,没有问题;
又试了下9.13,提示dbms=execl2003出错,改为dbms=excel就ok了。

地板
sopching 发表于 2011-3-18 01:01:12
猫头鹰同学 代码没什么问题的。应该是excel导入的问题。

7
ttklkl 发表于 2011-3-18 09:19:43
5# baoaibaobao

我这是正版的SAS9.13,下面是运行结果:

1 data a;
2
3 input center $ scrono $ seqno weight height sbp subinit $;
4
5 cards;
NOTE: SAS went to a new line when INPUT statement reached past the end of a line.
NOTE: The data set WORK.A has 4 observations and 7 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds

15 ;
16
17 run;
18
19 proc import datafile='E:\aa.xls' out=aa
20
21 dbms=excel replace;
22
23 scantext=yes;
24
25 getnames=yes;
26
27 run;
NOTE: .AA was successfully created.
NOTE: PROCEDURE IMPORT used (Total process time):
real time 0.51 seconds
cpu time 0.12 seconds

28
29 proc sql noprint;
30
31 select b.name into:name separated by ' '
32
33 from aa as a inner join
34
35 (select name from dictionary.columns
36
37 where libname='WORK' and memname='A') as b
38
39 on a.variables=b.name;
ERROR: Column variables could not be found in the table/view identified with the correlation name
A.
ERROR: Column variables could not be found in the table/view identified with the correlation name
A.
40
41 quit;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):
real time 0.03 seconds
cpu time 0.00 seconds
WARNING: Apparent symbolic reference NAME not resolved.
42
43 %put &name;
&name
44

45 data a;
46
47 set a;
48
49 keep &name;
-
22
----
202
WARNING: Apparent symbolic reference NAME not resolved.
ERROR 22-322: Syntax error, expecting one of the following: a name, ;, _ALL_, _CHARACTER_,
_CHAR_, _NUMERIC_.
ERROR 202-322: The option or parameter is not recognized and will be ignored.
50
51 run;
WARNING: The variable name in the DROP, KEEP, or RENAME list has never been referenced.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.A may be incomplete. When this step was stopped there were 0
observations and 0 variables.
WARNING: Data set WORK.A was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.03 seconds
cpu time 0.00 seconds
Stay Hungry. Stay Foolish.

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

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-21 23:20