楼主: liushiping_4567
3300 14

如何按两个数据库变量值一致,生成新的变量 [推广有奖]

  • 0关注
  • 0粉丝

大专生

28%

还不是VIP/贵宾

-

威望
0
论坛币
77 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
2411 点
帖子
53
精华
0
在线时间
31 小时
注册时间
2016-8-16
最后登录
2017-9-4

相似文件 换一批

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
我想请教各位,在SAS里面如果按下面的要求写程序,当一个数据库中 sex=1 与 另一个数据库 gender=1 时,然后当一个数据库中 time=34 和 另一个数据库 agedays=34 匹配时,再生成新变量y=m*s.谢谢各位赐教! 1.png 2.png

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:变量值 数据库 Gender days time 数据库 如何

沙发
zwnSAS121 发表于 2017-3-21 14:49:44 |只看作者 |坛友微信交流群
data table1;
input no gender time;
cards;
55.5 1 34
54.8 1 32
50.0 2 43
58.2 1 43
56.0 2 31
;
data table2;
input sex agedays m s;
cards;
1 33 55.0714 0.03544
1 34 55.2049 0.03539
1 35 55.3374 0.03534
1 37 55.5992 0.03524
1 43 56.1104 0.03496
;

proc sql noprint;
create table table3 as
select
a.sex,
a.agedays,
a.m,
a.s,
m*s as y
from table2 as a
where sex in
(select gender
from table1) and
  agedays in
(select time
from table1);
quit;

使用道具

藤椅
liushiping_4567 发表于 2017-3-21 15:07:19 |只看作者 |坛友微信交流群
zwnSAS121 发表于 2017-3-21 14:49
data table1;
input no gender time;
cards;
非常谢谢亲,还想请教,怎样生成y=(no-m)*s?就是要用到两个表的变量

使用道具

板凳
zwnSAS121 发表于 2017-3-21 15:18:04 |只看作者 |坛友微信交流群
proc sql noprint;
create table table3 as
select
a.no,
b.sex,
b.agedays,
b.m,
b.s,
m*s as y,
(no-m)*s as y1
from table1 as a,
     table2 as b
where a.gender = b.sex
and   a.time   = b.agedays
;
quit;

使用道具

报纸
liushiping_4567 发表于 2017-3-21 17:21:52 |只看作者 |坛友微信交流群
zwnSAS121 发表于 2017-3-21 15:18
proc sql noprint;
create table table3 as
select
解决了,非常谢谢亲~希望以后有又不懂的地方,还可以请教~

使用道具

地板
liushiping_4567 发表于 2017-3-22 16:07:43 |只看作者 |坛友微信交流群
zwnSAS121 发表于 2017-3-21 14:49
data table1;
input no gender time;
cards;
我还有一个疑问想请教一下,首先,表1的NO1少,表2的NO1多,所以从表2中选出表1中所有的NO1,表2中包含所有表1的NO1,其实就是要求表2的NO1与表1的NO1变量值相同,并保留表2其他所有的变量,而表2还有很多变量,有字符型、日期型和数字型,这个程序在SAS中怎么写?谢谢~

使用道具

7
zwnSAS121 发表于 2017-3-24 13:19:10 |只看作者 |坛友微信交流群
proc sql noprint;
create table table3 as
select
a.no,
b.*,
m*s as y,
(no-m)*s as y1
from table1 as a,
     table2 as b
where a.gender = b.sex
and   a.time   = b.agedays
and   a.no     = b.no
;
quit;

使用道具

8
liushiping_4567 发表于 2017-3-30 22:28:36 |只看作者 |坛友微信交流群
zwnSAS121 发表于 2017-3-24 13:19
proc sql noprint;
create table table3 as
select
谢谢亲~

使用道具

9
liushiping_4567 发表于 2017-4-4 11:11:35 |只看作者 |坛友微信交流群
zwnSAS121 发表于 2017-3-24 13:19
proc sql noprint;
create table table3 as
select
大神 我想问下,我想用proc nlmixed 程序进行二分类反应变量的两水平模型分析,在这个语句中,模型的参数是不是要用proc glimmix 语句进行参数的估计?于是我用以下程序:
proc glimmix method=rspl data=A;
class people;
model lowweightWAZ=month motheragedegree fatheragedegree mothereducation fatherBMIdegree fathereducation income inhabitant miscarriage parity gravidity gestation gender gwgdegree delivery preparation drink exercise vomit vaginal smoke noise computer phone depressiondegree nightfeed feeding breastnumber sleep sleeptime activity cold diarrhea complementaryfeedingtime motherBMIdegree/S dist=binary link=logit ddfm=bw;
random month motheragedegree fatheragedegree mothereducation fatherBMIdegree fathereducation income inhabitant miscarriage parity gravidity gestation gender gwgdegree delivery preparation drink exercise vomit vaginal smoke noise computer phone depressiondegree nightfeed feeding breastnumber sleep sleeptime activity cold diarrhea complementaryfeedingtime motherBMIdegree/subject=people;
nloptions tech=nrridg;
run;
出来的结果显示,有点参数为0,那我在proc nlmixed语句中那些参数为0,设置参数值为0吗?
还是我写的程序有问题?谢谢指点~

使用道具

zwnSAS121 发表于 2017-3-24 13:19
proc sql noprint;
create table table3 as
select
还有 我想问:
我按下面程序:
proc nlmixed data=A;
parms b0=0.3619 b1=9.2584 b2=0.1223 b3=-0.7684 b4=-0.8946 b5=-0.5084 b6=-0.1055 b7=0.5279 b8=0.5699 b9=0.9933 b10=1.1098 b11=0.211 b12=3.2812 b13=-0.3272 b14=0.466 b15=-1.0409 b16=-0.5441 b17=22.462 b18=-0.5337 b19=0.1345 b20=0.4873 b21=0.5315 b22=10.3754 b23=-1.1663 b24=1.3985 b25=-1.2495 b26=-0.2036 b27=-0.2045 b28=0.05201 b29=-0.03028 b30=-0.04162 b31=-0.02524 b32=0.5906 b33=-0.2547 b34=-0.2493 b35=-0.2544 sigma=1;
y=b0+u+b1*month+b2*motheragedegree+b3*fatheragedegree+b4*mothereducation+b5*fatherBMIdegree+b6*fathereducation+b7*income+b8*inhabitant+b9*miscarriage+b10*parity+b11*gravidity+b12*gestation+b13*gender+b14*gwgdegree+b15*delivery+b16*preparation+b17*drink+b17*exercise+b19*vomit+b20*vaginal+b21*smoke+b22*noise+b23*computer+b24*phone+b25*depressiondegree+b26*nightfeed+b27*feeding+b28*breastnumber+b29*sleep+b30*sleeptime+b31*activity+b32*cold+b33*diarrhea+b34*complementaryfeedingtime+b35*motherBMIdegree;
p=1/(1+exp(-y));
model lowweightWAZ~binary(p);
random u~normal(0,sigma) subject=people;
title 'only slope is random';
run;
结果出现ERROR: Quadrature accuracy of 0.000100 could not be achieved with 31 points.  The achieved accuracy was 1.000000.
这一问题该如何解决?

使用道具

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-4-19 11:16