楼主: 数理统计123
2756 8

[实际应用] 求助sas大神 [推广有奖]

  • 1关注
  • 1粉丝

已卖:1019份资源

博士生

37%

还不是VIP/贵宾

-

威望
0
论坛币
1967 个
通用积分
9.9531
学术水平
1 点
热心指数
4 点
信用等级
1 点
经验
1344 点
帖子
48
精华
0
在线时间
486 小时
注册时间
2013-4-26
最后登录
2025-8-18

楼主
数理统计123 发表于 2019-5-26 07:32:47 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
运行老师给的sas代码,为什么总出现library is not assigned的提示?
怎样解决?

二维码

扫码加我 拉你入群

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

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

关键词:assigned Library assign BRARY sas代码 sas 数据库

沙发
l1i2n3i4n5g 在职认证  发表于 2019-5-27 09:21:58
SAS默认是work逻辑库,如果用其他逻辑库,要先用libname语句指定,比如libname aaa 'C:\test';,之后就可以用data aaa.student;...

藤椅
数理统计123 发表于 2019-5-27 22:54:55
l1i2n3i4n5g 发表于 2019-5-27 09:21
SAS默认是work逻辑库,如果用其他逻辑库,要先用libname语句指定,比如libname aaa 'C:\test';,之后就可以 ...
还是不太懂,老师给的是这样的代码,怎么建立新的逻辑库
proc import datafile = 'C:\...\Momentum\treturn.xlsx'
out=momentum.treturn1 dbms=xlsx replace; sheet=sheet1; getnames=yes; run;
       
/* 2) Transpose the data for ease of SAS code implementation */;
proc transpose data=momentum.treturn1 out=momentum.treturn2; by Symbol; run;

/* 3) Create nyear(Calendar year), nmonth(Calendar month) */;
data momentum.treturn3(drop=_NAME_ year month);
set momentum.treturn2(drop=_LABEL_); rename COL1=tret;
year=SUBSTR(_NAME_,2,4); * Trim off some letters in a character string;
month=SUBSTR(_NAME_,6,2); * Trim off some letters in a character string;
nyear=input(year,4.); * Convert characters into a 4-digit number;
nmonth=input(month,2.); * Convert characters into a 2-digit number;
gijun_ym=nyear*100+nmonth;
run;

/* 4) Reorder variables */;
proc sql;  create table momentum.treturn4 as select Symbol, gijun_ym, nyear, nmonth, tret from momentum.treturn3; quit;

/* 5) Separate into subperiods */;
data momentum.return2(drop=tret);
set momentum.treturn3;
treturn=tret/100;
if gijun_ym<200007 then delete;
*if gijun_ym<200005 then delete;
*if gijun_ym>200912 then delete;
time=(nyear-2000)*12+nmonth-6;
run;
proc sort data=momentum.return2 out=momentum.return2sort;
by symbol gijun_ym;
run;

板凳
l1i2n3i4n5g 在职认证  发表于 2019-5-28 09:18:00
libname Momentum 'C:\...\Momentum';
proc import datafile = 'C:\...\Momentum\treturn.xlsx'
……
已有 1 人评分热心指数 收起 理由
eijuhz + 1 精彩帖子

总评分: 热心指数 + 1   查看全部评分

报纸
reduce_fat 发表于 2019-5-28 09:26:27
如果你的电脑里所存数据和老师给的不是一个data path 就不能用。 你得到文件夹里找properties 复制数据的 data path.

地板
数理统计123 发表于 2019-5-28 20:00:39
l1i2n3i4n5g 发表于 2019-5-28 09:18
libname Momentum 'C:\...\Momentum';
proc import datafile = 'C:\...\Momentum\treturn.xlsx'
……
做出来了,谢谢大神

7
数理统计123 发表于 2019-5-28 20:05:49
reduce_fat 发表于 2019-5-28 09:26
如果你的电脑里所存数据和老师给的不是一个data path 就不能用。 你得到文件夹里找properties 复制数据的 d ...
嗯嗯,做出来了

8
春天里赏百花 发表于 2019-6-2 20:35:23 来自手机
数理统计123 发表于 2019-5-26 07:32
运行老师给的sas代码,为什么总出现library is not assigned的提示?
怎样解决? ...
我来迟了   

9
数理统计123 发表于 2019-6-2 23:02:31
春天里赏百花 发表于 2019-6-2 20:35
我来迟了
后面有机会再请教

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

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-29 14:52