由买买提看人间百态

topics

全部话题 - 话题: datalines
首页 上页 1 2 3 4 5 6 7 下页 末页 (共7页)
y********0
发帖数: 638
1
来自主题: Statistics版 - 问SAS code怎么写
是用sql,转置一下,取个最小值就成。
data one;
infile datalines;
input id date mmddyy10.;
datalines;
1 08/12/2005
1 09/13/2005
2 01/09/2005
3 01/08/2005
3 01/08/2005
3 02/09/2005
;
proc transpose data=one out=two;
by id;
run;
proc sql;
select id,min(col1,col2,col3) as mdate format=mmddyy10.
from two;
quit;
t*********e
发帖数: 313
2
来自主题: Statistics版 - 请教下SAS Base 70题的第59题
data test;
infile datalines truncover;
length
Type $ 5
Color $ 11;
input
Type $
Color $;
datalines;
daisyyellow
;
run;
t**i
发帖数: 387
3
来自主题: Statistics版 - 一个SAS sql的问题
刚接触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 80000
Cindy HR 75000
Steven Sales 80000
;
data bonus;
input year dep $ bonus;
datalines;
2012 Sales 10000
2012 Marketing 1200... 阅读全帖
s**y
发帖数: 358
4
这是目前想到的方法,但觉得不够精炼,有没有更好的办法?
求大牛出来指点一下!
data one;
input @1 subject @5 date mdyampm25.2;
format date mdyampm25.2;
datalines;
1 01/08/2014 08:21:00 AM
1 01/08/2014 11:44:00 AM
2 01/11/2014 04:57:00 AM
2 01/11/2014 09:24:00 AM
3 01/07/2014 03:41:00 PM
3 01/07/2014 04:52:00 PM
...
;
format mdyampm25.2;
run;
data two;
input Subject Measure @13 Time mdyampm25.2;
format time mdyampm25.2;
datalines;
Subject Measure Time
1 10.50 01/07/2014 02:27:26 PM
1 7.10 01/08/2014 ... 阅读全帖
K*******5
发帖数: 98
5
来自主题: Statistics版 - [Help] SAS CODE FOR RANDOM SAMPLING
I need help for the SAS code Or if you have any idea. Thank you very much.
2 data sets: cases, controls.
Want to create a new data set, providing a random sample of controls at a
ratio of 5:1 matched for each observation from cases. do not worry about the
number of controls. I have enough controls for each case from my original
data.
Data cases;
Input site$ year$ id$;
Datalines;
A01 1996 c01
A02 1996 c02
A02 2000 c03
A03 1999 c04
……..
;
Data controls;
Input site$ year$ id;
Datalines;
A01 1996 1
... 阅读全帖
b*******z
发帖数: 155
6
来自主题: Statistics版 - 请问一道sas base的题
data temp;
infile datalines dsd;
input a $;
datalines;
RANCH,12322,2,1 AVENUE
;
run;
proc print data=temp;
run;
run出来,为什么a是RANCH而不是RANCH,12322,2,1呢
我记得infile的option如果不specify dlm的话,默认是space,为什么这里sas自动辨
认出dlm是逗号了呢
谢谢
b*******z
发帖数: 155
7
来自主题: Statistics版 - 请问这道sas题目
data test;
infile datalines;
input a $ 20 b $;
datalines;
indepent va
;
run;
我run出来是报错的,0 obs
但是sas 123题的第33题答案是 有1个obs ,b是missing value
想确认下这种情况到底是0还是1呢
m***w
发帖数: 69
8
来自主题: Statistics版 - 急问一个SAS 的常见问题
/* Generate the two SAS data sets */
data temp1;
input ID x y;
datalines;
1 1 2
2 2 3
3 3 4
4 4 5
5 5 6
6 6 7
;
run;
data temp2;
input ID x y;
datalines;
1 1 2
2 2 3
3 3 4
4 4 5
5 5 6
6 6 7
;
run;
/* Define the list of the variables */
%let var = x y;
%macro test();
/* Generate the variable for the SQL */
%let n = %sysfunc(countw(&var));
%let v = %scan(&var, 1, ' ');
%let qv = a.&v - b.&v as &v;
%do i = 2 %to &n;
%let v = %scan(&var, &i, ' ');
%let qv = &... 阅读全帖
w********r
发帖数: 238
9
code:
data test1;
input x y z;
datalines;
0 2 3
1 1 2
1 4 5
5 6 7
6 7 1
6 7 7
;
run;
data test2;
input x y z k;
datalines;
1 1 5 2
1 4 6 5
1 6 4 7
1 7 3 1
1 7 4 7
;
run;
data test;
set test1 test2;
if x^=1 then k=z;
run;
the output:
x y z k
0 2 3 3
1 1 2 3
1 4 5 3
5 6 7 7
6 7 1 1
6 7 7 7
1 1 5 2
1 4 6 5
1 ... 阅读全帖
d**m
发帖数: 42
10
来自主题: Statistics版 - 请教大家一个SAS问题
一个quiz的题不会,想请教大家一下,先多谢大家了!
The dataset below contains enrollment records for students. Write code to
count the number of days each student was enrolled. Include both the start
date and the end date in the count. Beware of overlapping date ranges. As an
example student 1’s count should be 6.
data Enrollment;
informat Start_Date MMDDYY10. End_Date MMDDYY10.;
format Start_Date MMDDYY10. End_Date MMDDYY10.;
infile datalines dlm=',';
input Student_Id Start_Date End_Date;
... 阅读全帖
a*z
发帖数: 294
11
来自主题: Statistics版 - 请问一个SAS proc sql的写法
use SAS proc sql case when.
Follow is my code. It works under SAS 9.4.
data A;
input id $ x y;
datalines;
01 3 4
02 4 5
03 5 6
04 6 7
;
run;
proc print; run;
data B;
input id $;
datalines;
02
04
06
;
run;
proc print; run;
proc sql;
create table want as
select A.*, case when id in (select id from B) then 1 else 0 end as idx
from A;
quit;
proc print; run;
Result:
Obs id x y idx
1 01 3 4 0
2 02 4 5 1
3 03 5 6 0
4 04 6 7 1
Try it out to see if this is what you want.
p******p
发帖数: 13
12
来自主题: Statistics版 - 请问一个SAS proc sql的写法
亲测可用,想覆盖data1的话把最后的new_data1改成data1就好,虽然覆盖源dataset习
惯很不好。
data data1;
input id t1 t2;
datalines;
1 2 3
2 4 5
3 4 5
;
run;
data data2;
input id;
datalines;
1
2
;
run;
proc sql noprint;
create table new_data1 as
select data1.*,coalesce(flag,0) as flag from
data1 left join (select data2.*,1 as flag from data2)
on data1.id=data2.id
;
quit;
s********a
发帖数: 154
13
来自主题: Statistics版 - 新手问个简单的sas问题
data dt1;
infile datalines;
input day $ x;
datalines;
1 0
1 0
1 0
2 0
2 1
2 1
2 0
2 0
3 1
3 0
;
run;
data dt2;
set dt1;
by day;
retain first_y;
if first.day then y = 0;
if x = 1 and y = 0 then do; y = 1; first_y = _N_; end;
if y gt 0 and first_y ne _n_ then y+1;
if last.day then output;
drop x first_y;
run;
w*******y
发帖数: 60932
14
FeaturesManufacturer Monster Cable Products, Inc
Manufacturer Part Number 109358
Power Cord/Cable 8 ft
Dimensions 2" Height x 11.5" Width x 4" Depth
Receptacles 8
Product Name PowerCentre HTS 850 8 Outlets Surge Suppressor
Weight 1 oz
Dataline Protection RJ-11 Phone
Dataline Protection Coaxial Cable Line
Linky:
http://cgi.ebay.com/Monster-PowerCenter-8-Outlet-Surge-Protecto
#ht_2630wt_1189" rel="nofollow" target="_blank" onclick="_gaq.push(['_
trackEvent', 'thread', 'click', '2653779 - ebay-dail... 阅读全帖
m****c
发帖数: 252
15
【 以下文字转载自 Seattle 讨论区 】
发信人: malloc (malloc), 信区: Seattle
标 题: 不得不说“唐骏”这样的人在中国很有土壤啊
发信站: BBS 未名空间站 (Wed Jan 6 11:03:47 2016, 美东)
比唐骏还唐骏,唐骏好歹也就是个学历造假,这位。。。。。。哎,以后微软人的简历
,还有谁能可以信。
他在微软也就是个PM2,连senior貌似都不是。当过几届CHIME的主席,。。。。敢忽悠
成这样子,牛!
http://www.ce.cn/xwzx/kj/201601/06/t20160106_8100045.shtml
世纪互联任命沈寓实担任集团副总裁兼云CTO
http://cpc.people.com.cn/n/2015/0123/c179979-26439385.html
一切从云计算重新开始
2006年谷歌首席执行官施密特在搜索引擎大会上提出产业“云计算”的概念后,不久之
后,微软公司时任首席执行官鲍尔默提出“尽在云中”(all in the cloud)的全新战
略,预示国际信息产业“云时代”即将来临。也就在2006... 阅读全帖
m****c
发帖数: 252
16
【 以下文字转载自 Seattle 讨论区 】
发信人: malloc (malloc), 信区: Seattle
标 题: 不得不说“唐骏”这样的人在中国很有土壤啊
发信站: BBS 未名空间站 (Wed Jan 6 11:03:47 2016, 美东)
比唐骏还唐骏,唐骏好歹也就是个学历造假,这位。。。。。。哎,以后微软人的简历
,还有谁能可以信。
他在微软也就是个PM2,连senior貌似都不是。当过几届CHIME的主席,。。。。敢忽悠
成这样子,牛!
http://www.ce.cn/xwzx/kj/201601/06/t20160106_8100045.shtml
世纪互联任命沈寓实担任集团副总裁兼云CTO
http://cpc.people.com.cn/n/2015/0123/c179979-26439385.html
一切从云计算重新开始
2006年谷歌首席执行官施密特在搜索引擎大会上提出产业“云计算”的概念后,不久之
后,微软公司时任首席执行官鲍尔默提出“尽在云中”(all in the cloud)的全新战
略,预示国际信息产业“云时代”即将来临。也就在2006... 阅读全帖
m****c
发帖数: 252
17
【 以下文字转载自 Seattle 讨论区 】
发信人: malloc (malloc), 信区: Seattle
标 题: 不得不说“唐骏”这样的人在中国很有土壤啊
发信站: BBS 未名空间站 (Wed Jan 6 11:03:47 2016, 美东)
比唐骏还唐骏,唐骏好歹也就是个学历造假,这位。。。。。。哎,以后微软人的简历
,还有谁能可以信。
他在微软也就是个PM2,连senior貌似都不是。当过几届CHIME的主席,。。。。敢忽悠
成这样子,牛!
http://www.ce.cn/xwzx/kj/201601/06/t20160106_8100045.shtml
世纪互联任命沈寓实担任集团副总裁兼云CTO
http://cpc.people.com.cn/n/2015/0123/c179979-26439385.html
一切从云计算重新开始
2006年谷歌首席执行官施密特在搜索引擎大会上提出产业“云计算”的概念后,不久之
后,微软公司时任首席执行官鲍尔默提出“尽在云中”(all in the cloud)的全新战
略,预示国际信息产业“云时代”即将来临。也就在2006... 阅读全帖
m****c
发帖数: 252
18
比唐骏还唐骏,唐骏好歹也就是个学历造假,这位。。。。。。哎,以后微软人的简历
,还有谁能可以信。
他在微软也就是个PM2,连senior貌似都不是。当过几届CHIME的主席,。。。。敢忽悠
成这样子,牛!
http://www.ce.cn/xwzx/kj/201601/06/t20160106_8100045.shtml
世纪互联任命沈寓实担任集团副总裁兼云CTO
http://cpc.people.com.cn/n/2015/0123/c179979-26439385.html
一切从云计算重新开始
2006年谷歌首席执行官施密特在搜索引擎大会上提出产业“云计算”的概念后,不久之
后,微软公司时任首席执行官鲍尔默提出“尽在云中”(all in the cloud)的全新战
略,预示国际信息产业“云时代”即将来临。也就在2006年,沈寓实加盟微软总部,负
责视窗视频、多媒体和流媒体的综合研发和系统整合。
===========真敢吹啊=========
三年后,沈寓实远赴印度,成立微软印度多媒体支持中心并担任技术主管。同年,由包
括时任微软亚太研发集团主席张亚勤博士在内的来自美国、中国... 阅读全帖
Y*********e
发帖数: 4847
19
来自主题: Sound_of_Music版 - 麦克杰克逊的录音
看到了Dataline的采访,里面流出一段MJ的谈话录音。
他说的2点
1,He is afraid of people
2, He wanted success and fame, because he wanted to be loved.
我觉得很有意思,也很真实。这个话题跟音乐没有关系,但是再发一下,以纪念他吧。
http://www.youtube.com/watch?v=g-CcqOe9WWU
l******y
发帖数: 60
20
大牛们,有没有可以import txt或 xls的sql命令?table 已经建好,但不用sqlloader
,也不用toad中的import功能,就是sql 命令,写入script可以直接运行的?
就像SAS 中的
data XXX
infile '.....a.txt'...
或者把文件中的内容直接输入,类似SAS中的 dataline.....,但不要一行一行地
insert
多谢啦
q****k
发帖数: 1023
21
I have no problem to use SAS Proc Logistic for an input data with aggregate
"count" variable.
But in SPSS, for the same input data with "count" variable, how to get the
similar "freq count" statement for SPSS Logistic Regression?
Thanks!
Please refer to
http://support.sas.com/rnd/app/da/cat/samples/chapter8.html
data coronary;
input sex ecg ca count @@;
datalines;
0 0 0 11 0 0 1 4
0 1 0 10 0 1 1 8
1 0 0 9 1 0 1 9
1 1 0 6 1 1 1 21
;
run;
proc logistic des... 阅读全帖
q****k
发帖数: 1023
22
I have no problem to use SAS Proc Logistic for an input data with aggregate
"count" variable.
But in SPSS, for the same input data with "count" variable, how to get the
similar "freq count" statement for SPSS Logistic Regression?
Thanks!
Please refer to
http://support.sas.com/rnd/app/da/cat/samples/chapter8.html
data coronary;
input sex ecg ca count @@;
datalines;
0 0 0 11 0 0 1 4
0 1 0 10 0 1 1 8
1 0 0 9 1 0 1 9
1 1 0 6 1 1 1 21
;
run;
proc logistic des... 阅读全帖
w*z
发帖数: 71
23
来自主题: Statistics版 - SAS daily tips
to input character variables with same prefix, one cannot use
data text;
input n1-n10 $;
datalinse;
smithers michaels gonzalez hurth frank bleigh
rounder joseph peters sam
;
run;
but you can use array do define them first:
data text;
array names{*} $ n1-n10;
array capitals{*} $ c1-c10;
input names{*};
do i=1 to 10;
capitals{i}=upcase(names{i});
end;
datalines;
smithers michaels gonzalez hurth frank bleigh
rounder joseph peters sam
;
run;
i********6
发帖数: 2
24
来自主题: Statistics版 - 一个sas问题,谢谢
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
;
RUN;
提示说日期的数据不对. 请问是哪里不对了, 谢谢.
'Invalid data for DATE in line 312 5-12.'
p********a
发帖数: 5352
25
来自主题: Statistics版 - 一个sas问题,谢谢
try this one:
DATA RESPOND;
FORMAT DATE mmddyy8. ;
INPUT @1 CALL_NO $3. @5 DATE mmddyy8. @14 TRUCKS $2. @17 ALARM 5.;
DATALINES;
001 10/21/94 03 2
002 10/23/94 01 1
003 11/01/94 11 3
RUN;
c*******7
发帖数: 2506
26
来自主题: Statistics版 - 请教sas code问题
一个只有一个变量x的dataset,有100行,现在需要把的25行和50行的两个数据取出,生成
一个新的有两个变量的dataset,每个变量只要一行.
data temp1;
input x;
datalines;
1
4
2
5
7
.
.
;
run;
data temp2;
retain y1 y2;
if _N_=25 then y1=x;
else if _N_=50 then y1=x;
else;
run;
这样得到的结果是100行的数据,而不是我想要的只有一行,两个变量的那种.
请问怎么写这个code呢?
h*******e
发帖数: 68
27
☆─────────────────────────────────────☆
antonioxy (有绿卡不如学CS) 于 (Tue Jul 25 20:56:28 2006) 提到:
好歹都是很资深的程序员了,还犯这种错误,一段大程序改下来真是烦死,比如说这么个
东东:
data d1;
input a b c;
datalines;
1 2 3
1 5 6
1 2 3
2 4 6
;
proc sort data=d1 nodup; by a; run;
这个sort就错了,为什么,运行一下就知道,根本不能去掉第三行重复的数据,正确的应


proc sort data=d1 nodup; by _all_; run;

proc sql;
create table d1 as
select distinct * from d1 order by a;
quit;
sql更好一点因为可以规定排序的变量。
☆─────────────────────────────────────☆
papertigra (长工胖头猪) 于 (T
r**e
发帖数: 163
28
来自主题: Statistics版 - 一个sas问题
我有一组longitudinal数据,有2个变量---时间和成绩,有大约1千个ID,用proc gplot现在已经得到了总体上这些数据成绩随时间变化的plot,也能得到单个ID成绩随时间变化的plot,如果我想知道,单个ID成绩随时间变化的plot有几种(是上升?下降?先上升后下降?先下降后上升)应该用什么命令阿?Thanks a lot.
data one;
input id time grades;
datalines;
1 1 5
1 2 6
1 3 7
2 1 6
2 2 7
2 3 1
3 1 4
3 2 3
3 3 4
4 1 5
4 2 5
4 3 7
;
p********a
发帖数: 5352
29
☆─────────────────────────────────────☆
raze (calm+down) 于 (Mon Jul 30 17:42:17 2007) 提到:
data one;
input id badname worsename$;
datalines;
1 1 t1
1 2 t2
1 3 t3
2 1 t1
2 2 t2
2 3 t3
2 4 t4
2 5 t5
2 6 t6
2 7 t7
2 8 t8
2 9 t9
2 10 t10
;
data two;
set one;
label badname="observation";run;
proc format;
value badname 1="v1"
2="v2"
3="v3"
4="v4"
5="v5"
6="v6"
7="v7"
8="v8"
9="v9"
10="v10";
p********a
发帖数: 5352
30
☆─────────────────────────────────────☆
raze (calm+down) 于 (Tue Aug 7 00:53:28 2007) 提到:
我用sas做了一个pie图,想拷到ppt里去,但是ppt背景是蓝色的,字是白色的。我sas得出
的pie图背景是白色的,字是 黑色的。怎么样能设置sas得出的pie图和ppt一样----背景
是蓝色的,字是白色的阿?多谢
以下是我的code
data one;
input id percent;
datalines;
1 24
2 5
3 2
4 10
5 8
6 15
7 3
8 1
9 32
;
proc gchart data=one;
pie id/sumvar=percent noheading
other=2
percent=outside
slice=outside;
run;
pattern1 color=black;
pattern2 color=blue;
pattern3 color=green;
pattern4 color=gray;
pattern5 color=lipk
p******a
发帖数: 41
31
来自主题: Statistics版 - 请教一sas programmm
data one;
input ID $ SUM;
datalines;
001 5
001 .
002 5
002 7
003 5
003 5
003 5
;
run;
proc sql;
select * from one
where ID in (select ID from one group by ID having std(sum) ne 0);
quit;
p******a
发帖数: 41
32
来自主题: Statistics版 - 请教一sas programmm
And in case all sum of the same ID are missing, you may want to check on avg
(sum):
data one;
input ID $ SUM;
datalines;
001 5
001 .
002 5
002 7
003 5
003 5
003 5
004 .
004 .
;
run;
proc sql;
select * from one
where ID in (select ID from one group by ID having std(sum) ne 0 and avg(sum
) ne .);
quit;
p******a
发帖数: 41
33
来自主题: Statistics版 - sas问题
data one;
input X Y $;
datalines;
1 A
2 B
3 A
4 *
1 A
2 B
3 A
4 *
1 B
2 A
3 A
4 A
;
run;
proc sql;
select * from one
where x not in (
select x from one
group by x
having sum(case when y='*' then 1 else 0 end)/count(*) > 0.2
);
quit;
z**********i
发帖数: 12276
34
来自主题: Statistics版 - sas问题
找到了.
data one;
input X Y $;
datalines;
1 A
2 B
3 A
4 *
1 A
2 B
3 A
4 *
1 B
2 A
3 A
4 A
;
run;
proc sql;
create table two as
select * from one
where x not in (
select x from one
group by x
having sum(case when y='*' then 1 else 0 end)/count(*) > 0.2
);
quit;
a********a
发帖数: 346
35
来自主题: Statistics版 - need help in sas(urgent)
My data and sas code are as following.
我想对score做个histogram,在这个histogram上,我想让x轴上显示score,y轴上显示
relative frequency。但是用上面的命令,结果y轴上显示的是percent。不知道怎么能
让y轴显示relative frequency,而不是percent。 太感谢了。
data one;
input score @@;
datalines;
73 72 77 79 80 82 84 84 86 80
;
run;
proc univariate;
histogram score/ endpoints=64.5 to 95.5 by 5;
run;
d*****w
发帖数: 684
36
来自主题: Statistics版 - 线性回归的SAS编程疑问
各位好,下面是我的一个线性回归的程序。我想扩展一点东西出来,请问该怎么办?
具体就是说在我 “plot r.*p."的时候,我能不能把residual和predicted的数据保存
到一个dataset中去? 因为我想做residual的normal probability plot,我又不知道
如何在regression procesure里面使用probplot,所以才想是不是可以先把数据保存下
来再说。
谢谢各位
data Class;
input Name $ Height Weight Age @@;
datalines;
Alfred 69.0 112.5 14 Alice 56.5 84.0 13 Barbara 65.3 98.0 13
Carol 62.8 102.5 14 Henry 63.5 102.5 14 James 57.3 83.0 12
Jane 59.8 84.5 12 Janet 62.5 112.5 15 Jeffrey 62.5 84.0 13
;
***************
x**********n
发帖数: 13
37
来自主题: Statistics版 - sas里怎么取相邻2个observation的差?
thanks,如果data复杂一点
data test;
input id date nnb sumnb;
datalines;
1 10 2 15
1 11 1 15
1 12 1 20
1 13 1 10
2 7 1 150
2 9 1 200
2 10 2 150
2 17 1 300
;
run;
我这么写的,可是output不太对,为什么obs2也是.?
data new;
set test;
by id;
if first.id then diff=.;
else diff=sumnb-lag(sumnb);
run;
Obs id date nnb sumnb diff
1 1 10 2 15
x**********n
发帖数: 13
38
来自主题: Statistics版 - sas里怎么取相邻2个observation的差?
thanks,如果data复杂一点
data test;
input id date nnb sumnb;
datalines;
1 10 2 15
1 11 1 15
1 12 1 20
1 13 1 10
2 7 1 150
2 9 1 200
2 10 2 150
2 17 1 300
;
run;
我这么写的,可是output不太对,为什么obs2也是.?
data new;
set test;
by id;
if first.id then diff=.;
else diff=sumnb-lag(sumnb);
run;
Obs id date nnb sumnb diff
1 1 10 2 15
a********a
发帖数: 346
39
来自主题: Statistics版 - help sas code for choosing control group
data one;
input lake $ bacteria;
datalines;
Pristine 3933
Pristine 458
Pristine 94
Vacation 862
Vacation 437
Vacation 538
Pleasant 4481
Pleasant 276
Pleasant 4208
Sardine 7456
Sardine 4394
;
I want to test the mean of different lakes. So I used the following sas code,
proc glm data=one;
class lake;
model bacteria=lake;
run;
I know sas will treat 'Vacation' lake as the control group. If I want to use
'Pristine' as control group, how do I write in sas code
C*********y
发帖数: 1424
40
来自主题: Statistics版 - hi, an interview question
原数据是
5 90 80 70 77 88 23
2 100 99 25
3 87 85 88 35
第一组数是考试的次数,其他的是考试分数,最后一个数是年龄
想出的效果是这样的
Obs SCORE1 SCORE2 SCORE3 SCORE4 SCORE5 NUMBER SUBJ AGE
1 90 80 70 77 88 5 1 23
2 100 99 . . . 2 2 25
3 87 85 88 . . 3 3 35
必须用array做
应该如何写这个code呢
我写的
Data scoreproblem;
array array_score[5] score1-score5;
if array_score[i]<60 then array_score[i]=" "@;
input N score1 score2 score3 score4 score5 age;
datalines;
5
y****n
发帖数: 46
41
来自主题: Statistics版 - hi, an interview question
Data scoreproblem;
array score(5) score1 score2 score3 score4 score5;
input N @;
do i=1 to n;
input score(i) @;
end;
input age;
drop i;
datalines;
5 90 80 70 77 88 23
2 100 99 25
3 87 85 88 35
;
run;
c**********n
发帖数: 80
42
来自主题: Statistics版 - 请教两个关于SAS的问题
谢谢~
对于第二个问题,我想把日期比如1/10/1960变成sas date:10
我的做法是直接input date mmddyy10. 但是说mmddyy10.的format找不到。mmddyyyy10
. 和mmddyyyy8.也是一样。
这种情况下怎么解决呢?BTW,yyyymmdd10. 不行。
我的数据是:
symbol date volume
symbol_1 10/12/1999 98
symbol_2 11/2/1999 2
symbol_3 6/15/1998 40
要求把date转换成sas date
log 如下:
1 data qqq;
2 set 'd:\sas\mysaslib\qp\arg';
3 input symbol $ volume;
4 run;
ERROR: No DATALINES or INFILE statement.
NOTE: The SAS System stopped processing this step be
a********a
发帖数: 346
43
来自主题: Statistics版 - overall mean in sas for several variables
I have a dataset like the following:
data one;
input x y z;
datalines;
1 2 2
2 4 1
. 3 3
3 . 1
;
run;
when we use
proc means data=one;
run;
sas will tell the mean for x , y and z, if I want to know the overall mean
for x ,y and z together, i.e. I treat x,y and z as one variable, how should
I do?
Thanks a lot.
s*********e
发帖数: 1051
44
来自主题: Statistics版 - overall mean in sas for several variables
second one just for fun.
data one;
input x y z;
retain xyz n;
xyz + sum(x, y, z);
n + n(x, y, z);
datalines;
1 2 2
2 4 1
. 3 3
3 . 1
;
run;
data two;
set one end = eof;
if eof then do;
mean = xyz / n;
output;
end;
keep mean;
run;
x**7
发帖数: 341
45
来自主题: Statistics版 - overall mean in sas for several variables
不错

second one just for fun.
data one;
input x y z;
retain xyz n;
xyz + sum(x, y, z);
n + n(x, y, z);
datalines;
1 2 2
2 4 1
. 3 3
3 . 1
;
run;
data two;
set one end = eof;
if eof then do;
mean = xyz / n;
output;
end;
keep mean;
run;
z*********o
发帖数: 541
46
title ’Choice of Chocolate Candies’;
data chocs;
input Subj c Dark Soft Nuts @@;
Set = 1;
datalines;
1 2 0 0 0 1 2 0 0 1 1 2 0 1 0 1 2 0 1 1
1 1 1 0 0 1 2 1 0 1 1 2 1 1 0 1 2 1 1 1
2 2 0 0 0 2 2 0 0 1 2 2 0 1 0 2 2 0 1 1
2 2 1 0 0 2 1 1 0 1 2 2 1 1 0 2 2 1 1 1
3 2 0 0 0 3 2 0 0 1 3 2 0 1 0 3 2 0 1 1
3 2 1 0 0 3 2 1 0 1 3 1 1 1 0 3 2 1 1 1
4 2 0 0 0 4 2 0 0 1 4 2 0 1 0 4 2 0 1 1
4 1 1 0 0 4 2 1 0 1 4 2 1 1 0 4 2 1 1 1
5 2 0 0 0 5 1 0 0 1 5 2 0 1 0 5 2 0 1 1
5 2 1 0 0 5 2 1 0 1 5 2 1 1 0 5 2 1 1 1
o****o
发帖数: 8077
47
来自主题: Statistics版 - 一个很疑惑的SAS日期问题
you can't use informat and position at the same time. The position code will
serve as $ informat of specific length. try to delete the 5-10 after DATE:
DATA RESPOND;
INFORMAT DATE MMDDYY8.;
INPUT CALL_NO 1-3 DATE TRUCKS 14-15 ALARM 17;
DATALINES;
001 10/21/94 03 2
002 10/23/94 01 1
003 11/01/94 11 3
;
run;
and for the second non-executable code, you forget a ";" after FORMAT statement
p********a
发帖数: 5352
48
来自主题: Statistics版 - how to trasform data.
data a;
input year loc $ id $;
datalines;
2007 NY a
2007 NY b
2008 CA c
2008 CA d
2008 CA e
2008 FL f
run;
proc sort data=a;
by year loc;
proc transpose data=a out=b(drop=_name_) prefix=all_id;
by year loc;
var id;
proc print;
run;
p********a
发帖数: 5352
49
来自主题: Statistics版 - how to trasform data.
data a;
input year loc $ id $;
datalines;
2007 NY a
2007 NY b
2008 CA c
2008 CA d
2008 CA e
2008 FL f
run;
proc sort data=a;
by year;
proc transpose data=a out=b(drop=_name_) prefix=all_id;
by year;
var id;
run;
proc sql;
create table a1 as
select distinct year,loc from a;
proc transpose data=a1 out=c(drop=_name_) prefix=all_loc;
by year;
var loc;
proc sql;
create table d as
select c.*, b.* from c,b
where c.year=b.year;
proc print;
run;
b********g
发帖数: 1
50
来自主题: Statistics版 - SAS base 87% pass today
At least 50% in base 50 and 123. Many thanks to this board.
Something new or unsure:
1
x='372';
y='234 ';
z='657';
how to get 372-234-657
a. cat('-',x,y,z)
b. catx('-',x,y,z)
c. x!!'-'!!y!!'-'!!z
d.x!!'-'!!left(y)!!'-'!!z
2 _'char'% function
data test;
input name $;
datalines;
Liu
Ellisa
Risa
Loui
;
run;
data test2;
set test;
name2=(_'i'%);
run;
what is the value(s) of name2?
3 where is format saved if not saved permanently?
4. FOUND function;
5 function (trch? not remembered) to cha
首页 上页 1 2 3 4 5 6 7 下页 末页 (共7页)