由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - sas question!!!
相关主题
SAS macro Debug大家说说这是电脑的错还是SAS的错
How to search all data files in a folder?问个sas adv的问题
A problem on PROC SQL为啥我的宏不被解释--SYMBOLGEN
sas and environmental variablesHelp: SAS code
SAS macro variable resolution question与Macro相关的字符函数
sas base 123 question 82 answer is wrong?SAS BASE Questions
请帮看一下这个简单的code为什么不work?请问如何把一个数据里所有的变量名后面都加个v?thanks.
SAS help : Proc datasetSAS base question
相关话题的讨论汇总
话题: data话题: note话题: 20120107话题: run话题: 201207
进入Statistics版参与讨论
1 (共1页)
g********3
发帖数: 123
1
I want to stack several sas datasets from one directory:
a_20120101
a_20120102
a_20120105
a_20120106
b_20120107
Any dataset like a_2012xxx is what I need. but the number is not consistent,
and b_20120107 should not be included.
what should I do?
d******9
发帖数: 404
2
try to use dread function
p***r
发帖数: 920
3
x command

【在 d******9 的大作中提到】
: try to use dread function
d******9
发帖数: 404
4
Or use macro to do it. Below codes works well, tested with few sample
datasets.
options mprint symbolgen;
data A_201201;
A=225;
run;
data A_201207;
A=226;
run;
data A_201205;
A=338;
run;
data R_201207;
A=338;
run;
data B_201279;
A=551;
run;
proc sql;
select memname into : tables separated by ' '
from sashelp.vtable
where libname='WORK' and upcase(substr(memname, 1,1))='A';
quit;
data combine;
set &tables;
run;
=============================
LOG:

45 data combine;
SYMBOLGEN: Macro variable TABLES resolves to A_201201 A_201205 A_201207 A_
201279
46 set &tables;
47 run;
NOTE: There were 1 observations read from the data set WORK.A_201201.
NOTE: There were 1 observations read from the data set WORK.A_201205.
NOTE: There were 1 observations read from the data set WORK.A_201207.
NOTE: There were 1 observations read from the data set WORK.A_201279.
NOTE: The data set WORK.COMBINE has 4 observations and 1 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds
A****t
发帖数: 141
5
用macro会方便一点
data _null_;
length filename $ 10;
input filename $;
call symput('y'||left(_n_), filename);
datalines;
a_20120101
a_20120102
a_20120105
a_20120106
b_20120107
;
run;
%put &y1 &y2 &y3 &y4 &y5;
g********3
发帖数: 123
6
Thank you very much, both work!
1 (共1页)
进入Statistics版参与讨论
相关主题
SAS base questionSAS macro variable resolution question
请教大家一个SAS使用mapped drive的问题sas base 123 question 82 answer is wrong?
请问SAS中如何将work中形成的文件拷贝出来 很多的请帮看一下这个简单的code为什么不work?
[SAS] Efficient way for subsetting data?SAS help : Proc dataset
SAS macro Debug大家说说这是电脑的错还是SAS的错
How to search all data files in a folder?问个sas adv的问题
A problem on PROC SQL为啥我的宏不被解释--SYMBOLGEN
sas and environmental variablesHelp: SAS code
相关话题的讨论汇总
话题: data话题: note话题: 20120107话题: run话题: 201207