由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - A SAS question
相关主题
新人报道,兼问SAS data set的问题请教一个SAS文件循环生成的小问题
请教data mining 的问题,在线等,谢谢!求助:SAS使用问题(读数据)
MySQL语句请教 (转载)请教一道SAS题
SAS ADV passed!!!请帮忙看3道SAS题。
请教一sas code请教SAS ODS to Excel
在SAS里面如何进行数组操作?请问 Proc Anova 里的 scheffe options 怎么解释
Need urgent helps: How to use DDE to import password-protected excel file into SAS?[合集] sas advance question
对应STATA的SAS CODEwhy this error in %if statement
相关话题的讨论汇总
话题: group话题: data话题: number话题: sets话题: create
进入Statistics版参与讨论
1 (共1页)
m*********7
发帖数: 343
1
I have a data set now including two variables, one is the results of an
experiment and another one is the group number. And I want to separate the data set into several small data sets with only one certain group number and results in that group. For example, if there are 8 observations with group number 1 or 2 or 3, and create three data sets; if with group number 1 or 2, and create two data sets; if with group number 1 to n, and create n data sets.
Can I use a loop to the number of max(group)
l*******n
发帖数: 13
2
try
%macro xxx(g);
proc sql;
create table table&g as
select a,b from tablename where a=&g;
run;quit;
%mend;
m*********7
发帖数: 343
3
Thanks for the replying. I tried this one, but it seems like creating one
table each time. Can I use something to create n table at one time, like a
loop function?
q**j
发帖数: 10612
4
you are greedy, but greed is good :)
1. get unique group numbers into a table.
proc sort data = yourdata out=group(keep=group) nodupkey;
by group;
run;
2 do a lot of preparation.
data _NULL_;
set group end=lastobs;
name = cats("group",group);
call symput(cats("group",_n_),name);
if _n_ = 1 then
do;
longname= name;
longgroupvalue= '"'||cats(group)||'"';
end;
else
do;
longname=cats(longname)|| " "||cats(name);
longgroupvalue = cats(longgroupvalue)||", "||'"'||cats(group)||'"';
end;
if lastobs then
m*********7
发帖数: 343
5
Wa~~ So detailed explanation! Thanks a lot! Seems complicated for me. I
guess I'll need sometime to go through it little by little later.
o****o
发帖数: 8077
6
here is a more general fast solution:
data have ;
input mth: yymmn6. a b c ;
cards ;
200801 1 2 3
200802 1 2 3
200802 4 5 6
200803 1 2 3
200803 4 5 6
200803 7 8 9
;
run ;
/* intentionally to disorder */
proc sort data=have; by c; run;
/* Apply the Hash List approach credited to Richard A. DeVenezia */
data _null_;
if _n_=1 then do;
declare hash h0(ordered:'YES');
h0.defineKey('mth');
h0.defineData('mth', 'a', 'b', 'c', 'h');
h0.defineDone();

【在 m*********7 的大作中提到】
: I have a data set now including two variables, one is the results of an
: experiment and another one is the group number. And I want to separate the data set into several small data sets with only one certain group number and results in that group. For example, if there are 8 observations with group number 1 or 2 or 3, and create three data sets; if with group number 1 or 2, and create two data sets; if with group number 1 to n, and create n data sets.
: Can I use a loop to the number of max(group)

1 (共1页)
进入Statistics版参与讨论
相关主题
why this error in %if statement请教一sas code
SAS 请教在SAS里面如何进行数组操作?
[合集] 请教一个percentile的问题 (SAS)Need urgent helps: How to use DDE to import password-protected excel file into SAS?
问一个简单的SAS问题,多谢对应STATA的SAS CODE
新人报道,兼问SAS data set的问题请教一个SAS文件循环生成的小问题
请教data mining 的问题,在线等,谢谢!求助:SAS使用问题(读数据)
MySQL语句请教 (转载)请教一道SAS题
SAS ADV passed!!!请帮忙看3道SAS题。
相关话题的讨论汇总
话题: group话题: data话题: number话题: sets话题: create