由买买提看人间百态

topics

全部话题 - 话题: lastobs
(共0页)
s********1
发帖数: 54
1
来自主题: Statistics版 - One question about %put
In the following code, I want to use "%put &status1" to show &status1=not.
But I did not see it in SAS log. Who can tell me why?
#######################################
data HIGHWAY;
input Steering $ Seatbelt $ Speed $ Status $ Count;
cards;
absent No 0-29 serious 31
absent No 0-29 not 1419
absent No 30-49 serious 191
absent no 30-49 not 2004
absent no 50+ serious 216
;
run;
%macro SPLIT;
proc sort data=HIGHWAY out=WORK.UNIQUES(keep=Status) nodupkey;
by Status;
run;
data fer;
set uniques end=Las... 阅读全帖
q**j
发帖数: 10612
2
来自主题: Statistics版 - A SAS question
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
k*****u
发帖数: 1688
3
来自主题: Statistics版 - 请教一个sas macro的问题
下面这组data,打算对列求和。 用data step可以如下做,现在打算把
sum1+summer1;
sum2+summer2;
sum3+summer3;
sum4+summer4;
换成用macro来改写,应该怎么写? 折腾了好久都没弄出来,求教。
我试着用array可以做,macro总是说有问题。谁能帮我写一下code? 谢谢
data wide;
input name $ summer1-summer4;
cards;
a 1 2 3 4
b 1 2 3 4
c 1 2 3 4
;
data sum_data;
set wide end=lastobs;
sum1+summer1;
sum2+summer2;
sum3+summer3;
sum4+summer4;
keep sum1-sum4;
if lastobs then output;
run;
proc print data=sum_data;
run;
s******r
发帖数: 1524
4
来自主题: Statistics版 - 请教一个sas macro的问题
%macro Test(Countt);
data sum_data;
set wide end=lastobs;
%do i =1 %to &Countt;
sum&i+summer&i;
%end;
keep sum1-sum&Countt;
if lastobs then output;
run;
%mend;
%Test(4);
错了不管。
k*****u
发帖数: 1688
5
来自主题: Statistics版 - 请教一个sas macro的问题
确实是对的
能不能再帮我看看,我这么写为什么不对
%macro sumv(maxobs=);
%do i=1 %to &maxbos;
asum&i+summer&i
%if &i ne &maxobs %then ;
;
%end;
%mend;
data sum_data;
set wide end=lastobs;
%sumv(maxobs=4);
keep sum1-sum4;
if lastobs then output;
run;
a*****3
发帖数: 601
6
来自主题: Statistics版 - 请教一个sas macro的问题
话说没人喜欢看别人code where there are even typos not cleared (maxbos?). The
%if %then is also used in a weird fashion. Your code worked okay after i
deleting everything i did not understan:
%macro sumv(maxobs=);
%do i=1 %to &maxobs;
sum&i+summer&i ;
%end;
%mend sumv;
option mlogic mprint symbolGEN;
data sum_data;
set wide end=lastobs;
%sumv(maxobs=4) ;
keep sum1-sum4;
if lastobs then output;
run;
杀牛给点伪币吧 马上到年关了
o**********a
发帖数: 330
7
来自主题: Statistics版 - ADV SAS 63题中的第23题
Item 23 of 63 Mark item for review
Given the SAS data set SASUSER.HIGHWAY:
Steering Seatbelt Speed Status Count
-------- -------- ----- ------- -----
absent No 0-29 serious 31
absent No 0-29 not 1419
absent No 30-49 serious 191
absent no 30-49 not 2004
absent no 50+ serious 216
The following SAS program is submitted:
%macro SPLIT;
proc sort
data=SASU... 阅读全帖
s*********e
发帖数: 944
8
来自主题: Statistics版 - 请问Adv 63题 的第23题
options nodate nocenter formdlim='*';
data highway;
input Steering $ Seatbelt $ Speed $ Status $ Count;
cards;
absent No 0-29 serious 31
absent No 0-29 not 1419
absent No 30-49 serious 191
absent no 30-49 not 2004
absent no 50+ serious 216
run;
%macro split;
proc sort data=highway out=work.uniques(keep=status) nodupkey;
by status;
run;
data _null_;
set uniques end=lastobs... 阅读全帖
F*******1
发帖数: 75
9
来自主题: Statistics版 - 问个SAS 数据读入的问题
请教一个SAS 数据读入的问题. 我有个样本文件. 见附件.
我只需要第6行到第11行的数据. 在data statement 中, 我可以用firstobs=6 来定位
起事行. 那用什么来定位末位行呢? 我试了lastobs=11 不work. 谢谢!
如果我先读入所有数据,再提取需要的数据.我的sas script 如下. 但结果不对, 第7行
到第11行的数据丢了. 是什么原因呢? 谢谢!
data RT1;
%let _EFIERR_ = 0; /* set the ERROR detection macro variable */
infile "\\mkscsas01\saswork\20090108_asm_rtmcp_final.csv" delimiter =
',' MISSOVER DSD lrecl=55010 firstobs=6 ;
format Pnode $12. MCPType $12.;
INPUT Pnode $ Zone $ MCPType $ HE1 - HE24;
run;
D******n
发帖数: 2836
10
because sas didnt intend to have any logic in the first place, its logic was
just line by line processing. As more and more ppl used SAS and ppl asked f
or more and more functionalities , SAS developers just keep adding those wei
rd syntax/logic to SAS, just like patches.
one example is , you have firstobs in data step, but you dont have lastobs,
because obs= is it!
Why? because SAS developers first added obs=, as users wanted to print first
couple of lines, and then ppl wanted to get started no
(共0页)