由买买提看人间百态

topics

全部话题 - 话题: notsorted
1 (共1页)
x*****n
发帖数: 5
1
来自主题: Statistics版 - 求问一个SAS编程的问题
by letter notsorted;
notsorted能解释下吗?
s******a
发帖数: 184
2
来自主题: Statistics版 - 帮忙看看这段SAS程序
proc format;
   value  qtrfmt  ’01jan2002’ d - ’31mar2002’ d = ’1’
’01apr2002’ d - ’30jun2002’ d = ’2’
         ’01jul2002’ d - ’30sep2002’ d = ’3’
’01oct2002’ d - ’31dec2002’ d = ’4’;
run;
data company.quarters(keep=count order_date
rename=(order_date=Quarter));
set retail.orders;
format order_date qtrfmt.;
by  order_date  groupformat  notsorted;
where year(order_date)=2002;
if first.order_date then Count=0;
Count +1;
if last.order_date;
run;
我对这段程序有两个问题:
1) 我知道这三行
if first.order_date... 阅读全帖
k*****u
发帖数: 1688
3
来自主题: Statistics版 - 这段SAS程序怎么理解?
为什么先出现 do until (last.high) 这一段? 而 by high notsorted 还在后面呢?
不是应该有了by以后才会有first. 和 last. 这两个么?
一直不明白 求解惑
谢谢
data want;
retain min max;
do until (last.high);
set tmp1.have;
by high notsorted;
if first.high then do;
min=p_sm;
max=p_sm;
end;
else do;
min=min(min,p_sm);
m... 阅读全帖
s******o
发帖数: 283
4
来自主题: Statistics版 - SAS adv question.请大家帮忙看看
thanks for your help,
but from SAS base "reading SAS dataset----using By-group processing" it
says,
"When you use the BY statement with the SET statement,
the data sets that are listed in the SET statement must be sorted by the
values of the BY variable(s), or they must have an appropriate index."
so answer B is possible?
and from adv-prep-guide,
"The NOTSORTED option can be used with FIRST.variable and LAST.variable,
example:
data work.new;
set company.sales
by ordername notsorted;
run;
"
so an... 阅读全帖
a********g
发帖数: 651
5
来自主题: Statistics版 - SAS ADV passed!!!
昨天终于考完ADV了,前后复习了1个多月,从本版得到了很大的帮助。前面的几个总结
性的帖子很管用,特别是pricematch 的帖子提到的,我基本上都考到了。
下面具体的说说我考的题目。
SQL:
各种的join都有涉及,和merge,set a, set b 的情况比较。
SQL insert 的格式
IC的使用
SQL中index 和view的基本用法。
Dictionary.table
MACRO:
很多%在一起的结果,有2题
Automacro 中sysday and sysdate的区别
特别要注意的一个考点,这个是我没有在online tutor 中见到的:
Call symput 的用法,其输出什么情况下在local,什么情况在global。
Symput and symputx 的区别,这个自己瞎蒙的。
%let在什么地方,是否影响symput
Efficient:
前人已经说得很全面了,我只想补充几点。
Transpose 的用法
By groupformat
By x notsorted
Array的基本用法
If and select比较
hash object
z**k
发帖数: 378
6
来自主题: Statistics版 - 请教个SAS问题
汗,要说清楚
data table_a;
input id $ date $ char $;
datalines;
ID1 date1 A
ID1 date2 A
ID1 date3 L
ID1 date4 L
ID1 date5 A
ID1 date6 A
ID2 date7 B
;
data table_b;
set table_a;
by id char notsorted;
if first.id then inx=0;
if first.char then inx+1;
;
run;

:)
h****9
发帖数: 26
7
来自主题: Statistics版 - sas advance questions
Item 1 of 63 Mark item for review
When attempting to minimize memory usage, the
most efficient way to do group processing when
using the MEANS procedure is to use:
A.
the BY statement.
B.
GROUPBY with the NOTSORTED specification.
C.
the CLASS statement.
D.
multiple WHERE statements.
Item 45 of 63 Mark item for review
To create a list of unique Customer_Id
values from the customer data set, which
of the following techniques can be used?
A*******s
发帖数: 3942
8
来自主题: Statistics版 - [SAS] row merging
data a;
input A $ I L R;
cards;
a 0 1 2
a 0 3 4
a 1 5 6
a 1 2 3
a 0 4 5
a 0 5 9
;
run;
data b;
retain L1;
set a;
by i notsorted;
if i=0 and first.i=1 then do;
L1=L; delete;
end;
else if i=0 and last.i=1 then L=L1;
drop L1;
run;
p********a
发帖数: 5352
9
来自主题: Statistics版 - [SAS] row merging
by i notsorted ?
Fancy..
D******n
发帖数: 2836
10
来自主题: Statistics版 - [SAS] row merging
great i was using the same stragtegy but didnt know the notsorted keyword
and wish there was such function and it turned out it does....tnnd sas.
f*******e
发帖数: 51
11
来自主题: Statistics版 - 问个SAS 数据处理问题
mine
应该有更简单的
data test;
input name $ type;
cards;
A 1
A 1
A 2
B 1
C 1
C 3
C 2
;
run;
data temp;
length typeall $200;
retain typeall;
set test;
by name notsorted;
if first.name then typeall=strip(type);
else typeall=strip(typeall)||strip(type);
if last.name then output;
run;
proc sql noprint;
create table new as
select a.*, b.typeall
from test as a, temp as b
where a.name=b.name;
quit;
y****n
发帖数: 46
12
data old;
input x @@;
cards;
0 1 0 0 3 5 0 0 0 4
run;
data new;
set old;
by x notsorted;
if first.x then ct1=0;
ct1+1;
run;
proc sql;
create table test as
select x,count(*) as totct, max(ct1) as max_csct
from new
group by x;
quit;
s******y
发帖数: 352
13
data have;
input ID :$8. Visit Date :date9.
Unconfirmed_response :$8.;
cards;
1001 1 12JAN2009 SD
1001 2 13MAR2009 uPR
1001 3 28MAR2009 uPR
1001 4 02MAY2009 uPR
1001 5 31MAY2009 SD
1001 6 02AUG2009 uPR
1001 7 18AUG2009 uPR
1001 8 12SEP2009 SD
;
run;
data have;
set have;
by ID Unconfirmed_response notsorted;
gp+1*first.Unconfirmed_response-gp*first.ID;
run;
proc sql;
create table want as
select *,... 阅读全帖
a****m
发帖数: 693
14
data have;
set have;
by ID Unconfirmed_response notsorted;
firstID=first.ID;
firstUn=first.unconfirmed_response;
gp+1*first.Unconfirmed_response-gp*first.ID;
run;
在sas上run一下,看看就明白了,如果对first and Last 熟悉了就知道了。
还要谢谢微笑刺客smileguy.
d*******o
发帖数: 493
15
来自主题: Statistics版 - 求问一个SAS编程的问题
DATA ONE;
input letter $;
cards;
A
A
B
B
B
B
C
C
;
run;
data two;
retain count;
set one;
by letter notsorted;
if first.letter then count=0;
count+1;
run;
R*********i
发帖数: 7643
16
来自主题: Statistics版 - questions about a SAS code
Using the data in original stacking structure, assume variable name is var
and dataset name is test:
data test1;
set test;
by var notsorted;
retain counter;
if first.var then counter=1;
else counter=counter+1;
if last.var then output;
run;
proc sql;
select var,counter,n(counter) as numtimes
from test1
group by var,counter
order by var,counter;
quit;
o*****m
发帖数: 950
17
来自主题: Statistics版 - 谁用过surveyselect 啊, 救我啊
我运行以下
proc surveyselect data = basic
n=1000 out=samplesize;
strata client_id tier / alloc=prop nosample;
run;
But keep get error, saying
697 proc surveyselect data = basic
698 n=1000 out=samplesize;
699 strata client_id tier / alloc=nosample;
-
22
-----
202
ERROR: Variable NOSAMPLE not found.
ERROR 22-322: Syntax error, expecting one of the following: a name,... 阅读全帖
y****n
发帖数: 46
18
来自主题: Statistics版 - 求高人指点一个SAS数据的转换问题
data have;
input id $ num;
cards;
A 1
A 2
A 3
A 4
B 1
B 2
B 3
B 4
;
run;
proc sort data=have;
by num id;
run;
proc transpose data=have out=want(drop=_name_ num);
by num notsorted;
var num;
id id;
run;
l*********s
发帖数: 5409
19
来自主题: Statistics版 - 工作中的SAS 编程请教
data B(drop=count);
set A;
retain count;
by y notsorted;
if first.y then count=1;
else count+1;
if last.y then c=count;
if c=. then delete;
run;
k*******a
发帖数: 772
20
来自主题: Statistics版 - 工作中的SAS 编程请教
我也试过 by y,不过不行,原来要加 notsorted
学习了
y****n
发帖数: 46
21
来自主题: Statistics版 - sas 编程 - data manipulation
data want;
array xx(3) TypeA TypeB TypeC;
set have;
length TYPE $1;
by date SeriesNO notsorted;
do i=1 to 3;
TYPE=substr(vname(xx(i)),5);
AMOUNT=xx(i);
if AMOUNT ne . then output;
end;
drop TypeA TypeB TypeC i;
run;
r******m
发帖数: 369
22
来自主题: Statistics版 - SAS question
data test;
input id date$;
cards;
1 1/1/2011
1 1/2/2011
1 1/3/2011
1 1/3/2011
1 1/3/2011
1 1/3/2011
2 3/2/2000
2 3/3/2000
2 3/4/2000
2 3/4/2000
2 3/4/2000
2 3/7/2000
2 3/8/2000
run;
data new;
set test;
by date notsorted;
if first.date and last.date then flag=0;
else flag =1;
run;
k*******a
发帖数: 772
23
来自主题: Statistics版 - SAS code求助
假设你的data是a
data b;
set a;
if value=. then flag=1;
else flag=0;
run;
data c;
set b;
by flag notsorted;
if flag=1 then do;
if first.flag then flag=-1;
else if last.flag then flag=2;
end;
run;
这里的问题就是,如果连续missing只有1个的话,这个程序给的是2,如果希望其他数
值,可以相应调整
s******o
发帖数: 283
24
来自主题: Statistics版 - SAS adv question.请大家帮忙看看
do you mean if you use " notsorted " option in the by statement, it still
canot work?
s******o
发帖数: 283
25
来自主题: Statistics版 - SAS adv question.请大家帮忙看看
dido2009, thanks for your help, I actually run the code below:
data C;
input A B $;
cards;
5 t
5 W
7 h
1 a
9 D
;
run;
data B;
set C;
By A notsorted;
if first.A then output;
run;
and the SAS result is
5 t
7 h
1 a
9 D
so as you said answer C is possible( when data is in natural order). then
answer is D.
l******h
发帖数: 855
26
来自主题: Statistics版 - SAS ADV 63中的第一题
When attempting to minimize memory usage, the
most efficient way to do group processing when
using the MEANS procedure is to use:
A.
the BY statement.
B.
GROUPBY with the NOTSORTED specification.
C.
the CLASS statement.
D.
multiple WHERE statements.
我的答案显示的是C: class
however, 我实际操作了一下,发现用BY 的时间更短。请问是我哪里错了还是答案有误
G********L
发帖数: 12
27
可能要这样才能满足楼主的要求。
proc sort data=one;
by company year product;
run;
data two (drop=count temp1 temp2);
set one;
by year notsorted;
retain count temp1 temp2;
if _n_=1 then do;
temp2=0;
temp1=company;
end;
if temp1 NE company and first.year then temp2=count;
if first.year then count=0;

count+1;
newvar=temp2+count;
temp1=company;
run;
j*****7
发帖数: 4348
28
libname test "X:\XXX\XXX\XXX";
proc sql noprint;
create table ddfdata as
select memname as dataset label='Data Set Name',
name as variable label='Variable Name',
label label='Variable Label',
type label='Variable Type',
count (distinct memname) into :totmem
from sashelp.vcolumn where libname='TEST'
order by dataset,name;
quit;
%macro trans;
data _null_;
set ddfdata;
by dataset notsorted;
retain b 1;
if first.dataset then do;
call symput(compress(trim(left('member'||t... 阅读全帖
c**********2
发帖数: 62
29
来自主题: Statistics版 - 讨论3道SAS ADV题目
SAS ADV 63题网上的答案有很多版本,貌似都有一些错误。下面是我仍然拿不准的一些
题目。欢迎讨论,指正。等考完若有时间再把整理的63题答案发出来积点人品。
Item 1 of 63 Mark item for review
When attempting to minimize memory usage, the most efficient way to do group
processing whenusing the MEANS procedure is to use:
A. the BY statement.
B. GROUPBY with the NOTSORTED specification.
C.the CLASS statement.
D.multiple WHERE statements.
答案选C,个人也认为C是对的。网上有人提到过用Sort再means,这样A更快。但是题目
问的是memeory,不是时间,所以觉得还是应该选C。
Item 11 of 63 Mark item for review
The following SAS code is subm... 阅读全帖
1 (共1页)