p*****o 发帖数: 543 | 1 在DATA STEP中,有什么FUNCTION是可以让我只KEEP变量名中含有READING的变量么?
非常感谢 |
d*******1 发帖数: 854 | 2 需要MACRO才能搞定
【在 p*****o 的大作中提到】 : 在DATA STEP中,有什么FUNCTION是可以让我只KEEP变量名中含有READING的变量么? : 非常感谢
|
p*****o 发帖数: 543 | 3 macro如何做呢?
能给个提示么。。。
因为DATA很大,有几百个变量,其中大概40个变量名字中是含READING的,但是又不是
排列在一起的。所以很想知道有什么简单办法来做这个。
【在 d*******1 的大作中提到】 : 需要MACRO才能搞定
|
l***a 发帖数: 12410 | 4 try using
proc contents
index function
array macro variable
【在 p*****o 的大作中提到】 : macro如何做呢? : 能给个提示么。。。 : 因为DATA很大,有几百个变量,其中大概40个变量名字中是含READING的,但是又不是 : 排列在一起的。所以很想知道有什么简单办法来做这个。
|
p*****o 发帖数: 543 | 5 Thanks a lot.
And I will try it!!
【在 l***a 的大作中提到】 : try using : proc contents : index function : array macro variable
|
o******6 发帖数: 538 | 6 proc transpose and find function
【在 p*****o 的大作中提到】 : 在DATA STEP中,有什么FUNCTION是可以让我只KEEP变量名中含有READING的变量么? : 非常感谢
|
g********d 发帖数: 2022 | 7 proc sql;
select name
into :v1 - :v40
from sashelp.vcolumn
where libname='yourlibname'
and name contains 'READING'; quit;
data youroutputdata;
set youroriginaldata(keep=&v1 &v2 &v3 ... &v40);run;
【在 p*****o 的大作中提到】 : 在DATA STEP中,有什么FUNCTION是可以让我只KEEP变量名中含有READING的变量么? : 非常感谢
|
o******6 发帖数: 538 | 8 如果READING是前缀,更简单,KEEP READING:;就可
【在 p*****o 的大作中提到】 : 在DATA STEP中,有什么FUNCTION是可以让我只KEEP变量名中含有READING的变量么? : 非常感谢
|
p*****o 发帖数: 543 | 9 that is true. but its in the middle...
thanks a lot
【在 o******6 的大作中提到】 : 如果READING是前缀,更简单,KEEP READING:;就可
|
p*****o 发帖数: 543 | 10 great! and thank a lot.
actually i got another one similar to yours though I dont understand it at
all....
but thank you so much.
【在 g********d 的大作中提到】 : proc sql; : select name : into :v1 - :v40 : from sashelp.vcolumn : where libname='yourlibname' : and name contains 'READING'; quit; : data youroutputdata; : set youroriginaldata(keep=&v1 &v2 &v3 ... &v40);run;
|
|
|
l***a 发帖数: 12410 | 11 nice... smart way of doing this
one question, if I don't know the number of such variables is 40 or 400 or
whatever, how to make this more genetic?
【在 g********d 的大作中提到】 : proc sql; : select name : into :v1 - :v40 : from sashelp.vcolumn : where libname='yourlibname' : and name contains 'READING'; quit; : data youroutputdata; : set youroriginaldata(keep=&v1 &v2 &v3 ... &v40);run;
|
g********d 发帖数: 2022 | 12 "select name
into :V1 - :V9999999999999999999999999999999"
%put _user_;
then you'll see. If 999 variables, then only V1-V999 will be in the list.
So find the highest V, which is the number of such variables.
【在 l***a 的大作中提到】 : nice... smart way of doing this : one question, if I don't know the number of such variables is 40 or 400 or : whatever, how to make this more genetic?
|
o****o 发帖数: 8077 | 13 select name into :_varseq separated by ' '
......
【在 l***a 的大作中提到】 : nice... smart way of doing this : one question, if I don't know the number of such variables is 40 or 400 or : whatever, how to make this more genetic?
|
g********d 发帖数: 2022 | 14 ha, good
【在 o****o 的大作中提到】 : select name into :_varseq separated by ' ' : ......
|
o******6 发帖数: 538 | 15 proc transpose data=a out=b (drop=_label_);
var _all_;
run;
data b;
set b;
if find (_name_, "reading");
run;
proc transpose data=b out=c (drop=_name_);
var col:;
id _name_;
run; |