z****n 发帖数: 67 | 1 我有一个data set 叫做missing, 里面每个id对应的变量v1 - v5 都有缺省值。其中
id是a的
只有v1,v2和v5有缺省值,id是b的只有v1和v3有缺省值,id是c的v2 - v5都是缺省值
data missing;
input id$ v1 v2 v3 v4 v5;
datalines;
a 1 . 1 3 1
a . 2 1 4 2
a . 4 5 2 8
a 1 5 2 3 .
b . 9 2 3 2
b 5 9 2 4 4
b . 3 . 5 3
c 2 . . . .
;
接下来我根据每个id都有一个data set是补全所有缺省值的。例如:
data complete_a;
input id$ v1 v2 v5;
datalines;
a 1 2 1
a 2 2 2
a 3 4 8
a 1 5 6
;
data complete_b;
input id$ v1 v3 ;
datalines;
b 1 2
b 5 2
b 3 4
;
data complete_c;
input id$ v2 v3 v4 v5;
dataline |
|
a*****9 发帖数: 1315 | 2 i had this problem in class .
if then do end is a loop ; eq : if ;
data q;
infile datalines;
input City $20.;
if City='Tulsa'
State='OK';
Region='Central';
;
if City='Los Angeles'
State='CA';
Region='Western';
;
datalines;
Tulsa
Los Angeles
Bangor
;
run;
proc print data= q;
run;
data q;
infile datalines;
input City $20.;
if City='Tulsa' then do;
State='OK';
Region='Central';
end;
if City='Los ... 阅读全帖 |
|
t****h 发帖数: 113 | 3 【 以下文字转载自 Linux 讨论区 】
【 原文由 tonyzh 所发表 】
我现在用的平台是ipaq,linux kernel是2.4.18,java是blackdown的1.3.1
我用java sound API写一个播放声音文件的小程序,这个小程序在redhat或者windowsXP
下的JVM上跑都没有问题,可以播放声音文件(.wav)。然后我把这个程序放到ipaq上跑
结果就播放不了声音,整个程序在调用播放声音那里就停住了。我可以肯定的是,ipaq上
的声音设备是好的,因为其他非java写的播放器都可以播放声音出来。然后我就查看
dataline的情况,发现dataline的buffer很快就满了。按道理来说,我们往dataline的
buffer写数据,然后声音设备就会从buffer那里读数据,然后播放出来。
在一个mailling list上,我看到一个99年的post,一个人也抱怨有同样的问题。
后来,他发现java在播放声音的时候,实际上是在用/dev/audio来播放,而恰好
他没有对这个文件进行写操作的权限,后来他把权限给设了之后,就好了。
于是我就查看了一 |
|
i******n 发帖数: 839 | 4 I have some text to input today, so try the datalines which i have not used
for long time .
but sas jsut read the each other line, finally, guess how I solved the
problem:
I inserted blank row between datalines.
Data final;
input criteria $ 1-400;
datalines;
[1] xxuxt xxtxxxt >= 18 yxxrs xxx <= 90xxrs.
|
|
p****8 发帖数: 50 | 5 答案是A,为什么其他答案不对啊?我人认为因该选D。后面有我设计的test code。给
出相同结果。
Item 52 of 63 Mark item for review
To create a dataset with unique values of
a given varible using a data step and the
FIRST. and LAST. varaibales, it is assumed
that the input dataset is:
A.
sorted on that variable.
B.
indexed by that variable.
C.
naturally in order.
D.
any of the above A, B, or C
============================================
*natually in order;
data a0;
input x y z;
da... 阅读全帖 |
|
f**z 发帖数: 154 | 6 我有个问题向版上牛人们请教一下,是关于数据读取长度的。
如果在读取datalines或者inflies进来的数据时不用length定义数据长度,有什么办法
让SAS“自动”读不同长度的数据吗?比如:
data example;
length $10;
input abc $ @@;
datalines;
abcdefghij wxyz 123
;
如果不用length, 有别的方法正确读取数据吗?我的意思是如果数据长度可能很长,又
可能是未知的长度(比如是用infile读取的,而不是在datalines里的), 那是不是只
有设置length语句里的变量长度足够大是比较常用的方法呢?有没有别的方法呢?
谢谢! |
|
t**i 发帖数: 387 | 7 【 以下文字转载自 Statistics 讨论区 】
发信人: toni (toni), 信区: Statistics
标 题: 一个SAS sql的问题
发信站: BBS 未名空间站 (Mon Dec 30 16:18:39 2013, 美东)
刚接触SAS sql,有个问题求教:
现有2各表employees和bonus
employees表有列name, department, base_salary
bonus表有列year, department, bonus
现要用sql实现:返回employees表中所有的obs,用employees表中的department和year(
2012,2013)查询bonus表的bonus,给employees加上2列salary2012, salary2013
以下是我现有的一些code(不能同时返回2012和2013的total salary)
data employees;
input name $ dep $ base_salary;
datalines;
Charles Sales 70000
James HR 8000... 阅读全帖 |
|
p********a 发帖数: 5352 | 8 ☆─────────────────────────────────────☆
Bighappy (快乐大大大) 于 (Fri Apr 6 14:47:46 2007) 提到:
大侠帮忙看看下面的程序:
data dataA;
input var1 var2;
datalines;
1.2 2.0
4.2 3.2
3.8 1.8
6.0 9.3
7.5 5.4
8.6 7.2
;;;;
data dataB;
input var3 var4;
datalines;
2.1 2.4
2.3 7.2
3.4 2.8
9.4 5.5
5.5 5.9
7.8 7.2
1.1 1.4
4.5 6.5
;;;;
data new;
merge dataA dataB;
run;
proc print; run;
产出的结果如下:
Obs var1 var2 var3 var4
1 1.2 2.0 2.1 |
|
a********a 发帖数: 346 | 9 how can I get the same variable from three data sets at same time;
for example, in the following three data set, the weight is kept as either
numeric or character. Although I do not want the variable weight in the
final list, I could not get the variable ID and height because of the format
of the variable weight.
data one;
input ID name$ weight$ height;
datalines;
1 aa 120 180
2 bb 130 190
;
data two;
input ID name$ weight height;
datalines;
3 cc 100 165
4 dd 150 190
;
data three;
input ID name$ |
|
w***z 发帖数: 28 | 10 data publish;
infile datalines dsd;
input BookID $ Publisher: $25. Year;
datalines;
ASL32,SMITH AND SONS,1998
LAS484,MAJOR UNIVERSITY PRESS,1989
IOD859,SMITH AND SONS,1988
REU701,TOWN PRESS,1995
WRE142,LITTLE FEET,1990
;
run;
proc print data=publish;
run; |
|
s******r 发帖数: 1524 | 11 data test1;
input x;
datalines;
1
2
3
;
run;
data test2;
input y $1.;
datalines;
a
b
c
;
run;
proc sql;select x, y from test1 cross join test2;run;quit; |
|
c*****7 发帖数: 54 | 12 对于图1中的问题,我编的code如下(可以运行):
DATA RESPOND;
INPUT CALL_NO 1-3 @5 DATE MMDDYY8. TRUCKS 14-15 ALARM 17;
FORMAT DATE MMDDYY8.;
DATALINES;
001 10/21/94 03 2
002 10/23/94 01 1
003 11/01/94 11 3
;
PROC PRINT DATA=RESPOND;
RUN;
但是如果我按照如下两种code就运行不成功,但是一直不知道原因何在啊?
第一种:
DATA RESPOND;
INFORMAT DATE MMDDYY8.;
INPUT CALL_NO 1-3 DATE 5-12 TRUCKS 14-15 ALARM 17;
DATALINES;
001 10/21/94 03 2
002 10/23/94 01 1
003 11/01/94 11 3
;
PROC PRINT DATA=RESPOND;
RUN;
第二种:
DATA RESPOND;
INFORMAT DATE MMDDYY8.;
|
|
g*******y 发帖数: 380 | 13 data one;
input ID $ question $9.;
datalines;
001 question1
005 question1
009 question1
002 question2
003 question2
;run;
data two;
input ID $ question1 question2 question3;
datalines;
001 2 1 1
002 2 2 2
003 1 1 2
;
run;
proc sort data=two;
by ID;
run;
proc transpose data=two out=three name=question;
by ID;
run;
proc sql;
create table final as
select one.*, col1 from one, three
where one.ID=three.ID and one.question=three.question;
quit; |
|
C******t 发帖数: 72 | 14 很简单,用table number, rownumber来排序.
data set1;
input x y;
datalines;
1 2
3 4
5 6
;
data set2;
input w z;
datalines;
3 4
;
run;
data set1;
set set1;
setn=1;
rown=_n_;
run;
data set2;
set set2;
setn=2;
rown=_n_;
run;
proc sql;
create table combined (drop=setn rown)
as
select *
from set1
UNION all
select *
from set2
order by setn, rown; |
|
o******6 发帖数: 538 | 15 ☆─────────────────────────────────────☆
liqing (你快乐,所以我快乐。) 于 (Wed Mar 4 09:32:05 2009) 提到:
PLease see the following examples, could you please tell me what is wrong
with it? Thanks! I found even I use length statement, the value was still
cutted :(
data a;
input c $2. d;
datalines;
20 5
;
data b;
input d c $3. ;
datalines;
6 30e
;
data test;
length c $ 5 ;
set a b;
run;
proc print; run;
proc contents data=test;
run;
☆─────────────────────────────────────☆
ahab (ahab) 于 (Wed Ma |
|
w*********y 发帖数: 7895 | 16 我最近在练习SAS PROGRAMMING, 但是碰到这个难题. OUTPUT总是
不对. 加了 DLM=','后完全不对, 只用MISSING的话, DAYS那一个
基本是MISSING. 大家帮我看看吧. 谢谢大家了.
data kids;
infile datalines dlm=',' missover;
input subj origin $ sex $ grade $ type $ missingdays @;
do until (missingdays=.);
output;
input days @;
end;
input;
datalines;
1 A M F0 SL 2,11,14
2 A M F0 AL 5,5,13,20,22
;
run; |
|
y****n 发帖数: 46 | 17 I don't know if this is what you want.
data kids;
length temp_days $100;
infile datalines dlm=' ' truncover;
input subj origin $ sex $ grade $ type $ temp_days $;
wn=countw(temp_days,',');
do rec=1 to wn;
days=input(scan(temp_days,rec),best.);
output;
end;
drop temp_days wn;
datalines;
1 A M F0 SL 2,11,14
2 A M F0 AL 5,5,13,20,22
run; |
|
b*********e 发帖数: 29 | 18 SASHelp里边的好像不是例子用到的哈。还是我没找对路子?
有些例子自带了datalines,有些例子没有。(我猜这些没有的,可能在第一次用到的时
候,也给出了datalines了。可是,我们不可能一个一个例子翻阅这些help file呀。) |
|
a***r 发帖数: 420 | 19 data ld;
input (x y) ($);
datalines;
A A
A C
B B
B D
C A
C C
D B
D D
;
data list;
input x $;
datalines;
A
B
C
D
X
;
data temp(drop=temp);
set ld;
if x>y then do;
temp=x;
x=y;
y=temp;
end;
if x ne y;
run;
proc sql;
create table out as
select a.*
from list a left join (select distinct * from temp) as b
on a.x=b.y
where y is null;
quit;
office |
|
t*****n 发帖数: 167 | 20 有人做过这题吗?
17.Given the following data step:
data WORK.GEO;
infile datalines;
input City $20.;
if City='Tulsa' then
State='OK';
Region='Central';
if City='Los Angeles' then
State='CA'
Region='Western';
datalines;
Tulsa
Los Angeles
Bangor
;
run;
After data step execution, what will data set WORK.GEO contain?
A.
City State Region |
|
w********5 发帖数: 72 | 21 This is my answer. My codes are alway very long and not efficient. Please
help simlify.
data data1;
input var1;
cards;
5
6
;
run;
data data2;
input var2;
cards;
5
6
;
run;
data new;
infile datalines dlm=" ";
input name $ var $ ;
datalines;
data1 var1
data2 var2
data2 var2
data4 var4
;
run;
proc sql;
select name into:name1-:name&SYSMAXLONG
from new;
select var into:col1-:col&&SYSMAXLONG
from new;
quit;
%put _user_;
option mprint mlogic;
%macro mutiple;
%do i=1 %to &sqlobs;
proc so |
|
w********5 发帖数: 72 | 22 data name;
length name $100;
infile datalines dsd missover;
input name $;
datalines;
'KELLY SERVICES INC'
'FIDELITY HIGH INCOME INC'
'TALENT SERVICES -CL A'
;
run;
data name1;
set name;
Again=scan(name,1,' ')||" "||scan(name,2,' ');
run; |
|
g********d 发帖数: 2022 | 23 改了一下楼上那位大侠的。
假设最长的公司名只有5个,例子我改了一下为了测试。
attention那个变量是用来探测可能中间有“INC”,"-CL", "A"需要保留的,可能对你
没什么用,但是只是一个谨慎的思路。
data name;
length name $100;
infile datalines dsd missover;
input name $;
datalines;
'KELLY INC SERVICES INC'
'FIDELITY HIGH INCOME INC'
'A TALENT SERVICES -CL A'
'.'
;
run;
data name1;
set name;
A1=scan(name,1,' ');
A2=scan(name,2,' ');
A3=scan(name,3,' ');
A4=scan(name,4,' ');
A5=scan(name,5,' ');
array aa(5) A1-A5;
do i=1 to 5;
if aa(i)="INC" or aa(i)="-CL" or aa(i)="A" then aa(i)="";
e |
|
s******r 发帖数: 1524 | 24 It is bad idea. You are facing some uncertain.
For instance a company name is : xxxxx INCER**. you code would fail.
With limited word to remove, try something like
data name;
length name $100;
infile datalines dsd missover;
input name $;
if scan(name,-1)='INC' then
_name=substr(name,1, length(name)-3);
else if scan(name,-1,'-')='CL A' THEN
_name=substr(name,1, length(name)-6);
datalines;
'KELLY SERVICES INC'
'FIDELITY HIGH INCOME INC'
'TALENT SERVICES -CL A'
;
run; |
|
l**********s 发帖数: 255 | 25 再请问下,如果我的数据实际上变量很多,只需要处理其中的个5变量a1-a5,按照楼上
的指导确实可以做到,但是要
多合并一次文件,其他变量保持不变, 请问如果有没有办法用macro 或者array做呢?
多谢。
data one;
input ID a1 a2 a3 a4 a5 abc cnn nb;
datalines;
1 0 0 0 0 0 5 6 7
2 0 0 0 0 0 7 4 9
3 0 1 1 0 0 4 4 4
;
run;
data two;
input ID a1 a2 a3 a4 a5 abc cnn nb;
datalines;
1 . . . . . 5 6 7
2 . . . . . 7 4 9
3 0 1 1 0 0 4 4 4
;
run; |
|
s*******r 发帖数: 769 | 26 1. 为什么是A? 是不是State='CA'后面少了一个“;”?
data WORK.GEO;
infile datalines;
input City $20.;
if City='Tulsa' then
State='OK';
Region='Central';
if City='Los Angeles' then
State='CA'
Region='Western';
datalines;
Tulsa
Los Angeles
Bangor
;
run;
After data step execution, what will data set WORK.GEO contain?
A.
City State Region |
|
a*******m 发帖数: 6 | 27 The following SAS program is submitted:
data WORK.TEST;
drop City;
infile datalines;
input
Name $ 1-14 /
Address $ 1-14 /
City $ 1-12 ;
if City='New York ' then input @1 State $2.;
else input;
datalines;
Joe Conley
123 Main St.
Janesville
WI
Jane Ngyuen
555 Alpha Ave.
New York
NY
Jennifer Jason
666 Mt. Diablo
Eureka
CA
;
What will the data set WORK.TEST contain?
A.
Name Address State |
|
s*****p 发帖数: 299 | 28 data work.GEO;
infile datalines;
input city $20.;
if city = 'Tulsa' then
state = 'ok';
Region = 'central';
if city = 'Los Angeles' then
state = 'CA'
Region='western';
datalines;
Tulsa
Los Angeles
Bangor
;
run;
after data step execution, what will data set work.GEO contain?
Answer:
City state Region
Tulsa ok Western
Los Angeles CA Western
Bangor Western
为什么Tulsa 的Region会是 Western?不是CENTRAL?为什么Bangor 的 ... 阅读全帖 |
|
t**i 发帖数: 688 | 29 Set and Merge are not the same!
Try the following code:
data Dairy;
input Item $ Inventory Price ;
datalines;
Milk 15 1.99
Milk 3 1.99
Soymilk 8 2.99
Eggs 24 2.99
;
proc sort data=Dairy;
by Item;
run;
data Dairy2;
input Item $ Inventory Price;
datalines;
Soymilk 8 2.99
Eggs 24 2.99
Cheese 14 3.29
Yogurt 10 2.49
;
proc sort data=Dairy2;
by Item;
run;
data cc;
set Dairy Dairy2;
by Item;
run;
data dd;
merge Dairy Dairy2;
by It... 阅读全帖 |
|
p****8 发帖数: 50 | 30 data WORK.TEST;
drop City;
infile datalines;
input
Name $ 1-14 /
Address $ 1-14 /
City $ 1-12 ;
if City='New York ' then input @1 State $2.;
else input;
datalines;
Joe Conley
123 Main St.
Janesville
WI
Jane Ngyuen
555 Alpha Ave.
New York
NY
Jennifer Jason
666 Mt. Diablo
Eureka
CA
;
What will the data set WORK.TEST contain?
A.
Name Address State |
|
k*******a 发帖数: 772 | 31 Here is my solution, maybe too stupid:)
data a;
input planid level1 $;
datalines;
100 A
100 B
100 C
200 D
200 E
200 F
;
data b;
input planid level2 $;
datalines;
100 D
100 Z
200 H
;
data a;
set a;
by planid;
if first.planid then count=0;
count+1;
data b;
set b;
by planid;
if first.planid then count=0;
count+1;
data c;
merge a b;
by planid count;
drop count;
proc print data=c;run; |
|
d*******o 发帖数: 493 | 32 data have;
infile datalines dlm = ',';
retain row;
input myvar $ @@ ;
if prxmatch("/10\d/", myvar) ne 0 then row +1;
if missing(myvar) then delete;
datalines;
100, Grace, 3,1,5,2,6
101, Martin, 1,2,4
102, Scott, 9,10,4,
5, 6
103, Bob,2 ,1, 2, 2,4
;
run;
proc transpose data=have out=want(drop = row _name_);
by row;
var myvar;
run; |
|
s******y 发帖数: 352 | 33 filename temp temp;
data _null_;
length temp $200.;
retain temp;
file temp;
infile datalines eof=end;
input;
if not missing(temp) and prxmatch("/^\s*\d{3}\s*/",scan(_infile_,1,
','))=0
then do;
temp=cats(temp,_infile_);
return;
end;
else if _n_>1 and prxmatch("/^\s*\d{3}\s*/",scan(_infile_,1,','))>0
then put temp;
temp=_infile_;
return;
end:put temp;
da... 阅读全帖 |
|
D******n 发帖数: 2836 | 34 create a .vim directory under you home directory(there is a dot before
vim)
and then create a syntax directory under it
and then create a sas.vim file under the syntax directory
==============sas.vim======================
if version < 600
syntax clear
elseif exists("b:current_syntax")
finish
endif
syn case ignore
syn region sasString start=+"+ skip=+\\|\"+ end=+"+
syn region sasString start=+'+ skip=+\\|\"+ end=+'+
" Want region from 'cards;' to ';' to be captured (Bob Heckel)
sy... 阅读全帖 |
|
k*******a 发帖数: 772 | 35 data a;
infile datalines missover;
input x y;
datalines;
1 1
2 3
3 5
4 7
5
6
7
8
9
10
;
run;
proc sql;
create table b as
select x as z
from a
where x not in (select y from a);
quit;
data a;
merge a b;
run;
proc print data=a;run; |
|
t*****d 发帖数: 131 | 36 我想读入一组数据,用了以下的code,但是有错运行不了,想请问下大家该怎么改才能
把中间的引号去掉并正确读入数据呢?最近刚开始学sas,好多东西弄不太明白,谢谢
大家了!
data list;
infile datalines;
input id height weight;
datalines;
"1" "68" "144"
"2" "78" "202"
;
run; |
|
c*****a 发帖数: 808 | 37 you mean something like this? right joining tables?
data A;
input year qtr budget;
datalines;
2001 3 500
2001 4 400
2002 1 700
;
data B;
input year qtr sales;
datalines;
2001 4 300
2002 1 600
;
proc sql;
select A.budget, B.*
from A right join B on A.year=B.year;
quit; |
|
s******r 发帖数: 1524 | 38 data test;
LENGTH key1 8 key2 8 id1 8 id2 8;
FORMAT key1 BEST6. key2 BEST6. id1 $19. id2 $19.;
INFORMAT key1 BEST6. key2 BEST6. id1 $19. id2 $19.;
INPUT key1 : BEST6. key2 : BEST3. id1 : $19. id2 : $19.;
INFILE datalines DLM='7C'x MISSOVER DSD;
datalines;
18949|21|1942303098494173209 |1368841116323724091
;
run; |
|
j******o 发帖数: 127 | 39 Try this.
data one;
input id dt1 : mmddyy10.;
format dt1 mmddyy10.;
datalines;
1 4/4/2000
1 4/7/2005
1 9/2/2002
2 3/1/2003
2 2/3/2006
3 5/5/2009
;
run;
data two;
input id dt2 : mmddyy10.;
format dt2 mmddyy10.;
datalines;
1 5/1/1999
1 1/1/2007
2 9/8/2002
2 10/1/2002
2 1/2/2006
;
run;
proc sql;
create table obtain as
select a.id, coalesce(a.dt1, b.dt1) as dt1 format mmddyy10., b.dt2
from one a left join
(
select one.*, ... 阅读全帖 |
|
h*********1 发帖数: 102 | 40 data A;
input id dt1: mmddyy10.;
format dt1 mmddyy10.;
datalines;
1 4/4/2000
1 4/7/2005
1 9/2/2002
2 3/1/2003
2 2/3/2006
3 5/5/2009;
run;
data B;
input id dt2: mmddyy10.;
format dt2 mmddyy10.;
datalines;
1 5/1/1999
1 1/1/2007
2 9/8/2002
2 10/1/2002
2 1/2/2006;
run;
proc sql;
create table C as
select A.*, B.dt2
from A
left join B
on A.id=B.id and
(A.dt1 ge B.dt2 ge mdy(month(A.dt1),day(A.dt1),year(A.dt1)-1));
quit; |
|
l***i 发帖数: 8 | 41 Item 17 of 70 Mark item for review
Given the following data step:
data WORK.GEO;
infile datalines;
input City $20.;
if City='Tulsa' then
State='OK';
Region='Central';
if City='Los Angeles' then
State='CA';
Region='Western';
datalines;
Tulsa
Los Angeles
Bangor
;
run;
After data step execution, what will data set WORK.GEO contain?
The Answer is :
A.
City State Region
----------- ----- -------
Tulsa OK Wes... 阅读全帖 |
|
a*****9 发帖数: 1315 | 42
data a ;
input
name $10.
X1 X2 X3 ;
datalines;
mary 100 200 300
Jim Lee 130 210 450
Bryan Doi 220 430 560
Will 140 251 332
;
run;
proc print data=a;
run;
我run了一下, 还能行, 关键是我把这个datalines 稍微改了一下,
不知道版上高人在没改位置的情况下, 用什么code。
我可以明天去问一下我们的老师, 回头再来报告呀。 |
|
a*****9 发帖数: 1315 | 43
data a ;
input
name $10.
X1 X2 X3 ;
datalines;
mary 100 200 300
Jim Lee 130 210 450
Bryan Doi 220 430 560
Will 140 251 332
;
run;
proc print data=a;
run;
我run了一下, 还能行, 关键是我把这个datalines 稍微改了一下,
不知道版上高人在没改位置的情况下, 用什么code。
我可以明天去问一下我们的老师, 回头再来报告呀。 |
|
m*****y 发帖数: 229 | 44 I think the idea of hehehe is correct, but not necessary left join I think.
DATA A;
INPUT drug_id x;
datalines;
1 2
;
data B;
input drug_id y;
datalines;
1 4
;
proc sql;
select A.drug_id, x, y
from A,B
where A.drug_id=B.drug_id;
quit;
result:
drug_id x y
1 2 4
drug_ |
|
t****y 发帖数: 576 | 45 看到的答案是A,但实际运行结果state一栏全是empty value,想是因为city被drop,影响
了if statement. 这样一来根本就没有正确答案。
48.The following SAS program is submitted:
data WORK.TEST;
drop City;
infile datalines;
input
Name $ 1-14 /
Address $ 1-14 /
City $ 1-12 ;
if City='New York ' then input @1 State $2.;
else input;
datalines;
Joe Conley
123 Main St.
Janesville
WI
Jane Ngyuen
555 Alpha Ave.
New York
NY
Jennifer Jason
666 Mt. Diablo
Eureka
CA
;
What will t... 阅读全帖 |
|
x***I 发帖数: 91 | 46 最近在看sas programing in pharmaceutical industry.
看到作者用proc sql合并datasets,可是不知道为什么,最后一个记录出不全。
自己运行一下他的程序也是一样的,我用的是SAS9.2.
这个有什么办法解决么。
Program 4.8 Performing a Many-to-Many Join with PROC SQL
**** ADVERSE EVENTS;
data aes;
informat ae_start date9. ae_stop date9.;
input @1 subject_id $3.
@5 ae_start date9.
@15 ae_stop date9.
@25 adverse_event $15.;
datalines;
101 01JAN2004 02JAN2004 Headache
101 15JAN2004 03FEB2004 Back Pain
102 03NOV2003 10DEC2003 Rash
102 03JAN2004 10JAN2004 A... 阅读全帖 |
|
p***7 发帖数: 535 | 47 data work.geo;
infile datalines;
input city $20.;
in city='Tulsa' then state='OK';
Region='Central';
if City='LA'then state='CA';
Region='western';
datalines;
Tulsa
LA
BANGOR;
RUN;
After data step execution, what will data set WORK.GEO contain?
The answer is blow
A
CITY STATE REGION
TULAS OK WESTERN
LA CA WESTERN
Bangor WESTERN
I could not understand it. I know there should be @ in the input statement.
but why all the... 阅读全帖 |
|
l*******0 发帖数: 12 | 48 Can easily be done with any programming.
Here are SAS Codes.
DATA ad (DROP = StartDate EndDate i TotalAmt);
INFILE DATALINES DLM = ",";
INPUT WEB : $20. StartDate : mmddyy10. EndDate : mmddyy10. TotalAmt
DailyAmt;
DO i = 0 TO (EndDate - StartDate);
DATE = StartDate + i;
OUTPUT;
END;
DATALINES;
abc.com, 4/1/2012, 4/30/2012, 30000, 1000
esbn.com, 3/1/2012, 3/15/2012, 10000, 666.67
answer.com, 7/1/2012, 8/1/2012, 50000, 1612.9
;
RUN;
PROC SORT DATA =ad OUT = ad_sorted;
BY DATE;
RUN;
PROC PRI... 阅读全帖 |
|
l*******a 发帖数: 107 | 49 首先感谢这个版面给我了很大的信心和鼓励,感谢帮助过我的所有人!!!
现在我有个头疼的问题,一直很费解,拿到版上来请教下大家。我有两个data sets,
想得到这样的output结果:
this is the first sas data
FundingAmount 0-15000 0.217
ObjectAmount 15000-30000 0.318
FundingAmount 30000-60000 0.519
quit;
Next is the second sas data
Ashley Liu 17
brandon green 30
susan Chen 28
this is the end of the sas code
数据如下:
data data1;
input variableName $14. variableLength : $12. price;
datalines;
FundingAmount 0-15000 0.217
ObjectAmount 15000-... 阅读全帖 |
|
f******u 发帖数: 250 | 50 you do not need a macro.
data data1(keep=x);
input variableName $14. variableLength : $12. price;
x=catx(' ', variableName,variableLength,price);
datalines;
FundingAmount 0-15000 0.217
ObjectAmount 15000-30000 0.318
FundingAmount 30000-60000 0.519
;
run;
data data2(keep=x);
input firstname : $7.lastname : $7. age;
x=catx(' ',firstname,lastname,age);
datalines;
Ashley Liu 17
brandon green 30
susan Chen 28
run;
data data3;
set data1 data2;
run;
data _null_;
fil... 阅读全帖 |
|