D*********2 发帖数: 535 | 1 data structure:
1 col of character
3 cols of numeric
tried following ways:
1) .sas7bdat to .csv, then read.csv
problem: character be trimmed, eg. 007 to 7. I really need the trial number
to be 3 digits.
2) .sas7bdat to .txt, then read.table
problem: numeric variables be read as factor, say, 167.400, after using as.
numeric, it became 1674.
I also tried colClasses, but unless set the numeric cols to "factor" or "
character", there is an error message.
Thanks a lot!!!!!!!!!! |
|
d******y 发帖数: 244 | 2 I have a project to read .sas7bdat file using ado.net. Thanks in advance. |
|
y****a 发帖数: 536 | 3 看了ONLINE TUTORIAL,下载了需要分析的DATA,DATA后缀是.sas7bdat,双击试图打开
,然后就
出现CLASS CAN NOT REGISTERED的信息,各位大侠有没有遇到过,怎么能打开阿,还有
SAS和SAS
ENTERTAINMENT GUIDE 有什么区别亚,谢谢 |
|
|
c**********e 发帖数: 2007 | 5 I have data files with extension .sd7. I can view it, but found no
way to read it. Finally, I manually renamed the extensions to .sas7bdat.
Anybody knows the difference of the two extensions? Thanks! |
|
w**********y 发帖数: 1691 | 6 多年不用SAS,现在必须要用旧code来处理一批数据.头大中.
知道这里SAS高手多,请帮忙看看一个问题,多谢.
具体问题是这样的:
我要去wharton的WRDS里面download stock data.所有的文件都保存在他们的server上:'/wrds/taq/sasdata',每天的data是一个单独的file:
ct_20111222.sas7bdat, ct_20111223.sas7bdat, ct_20111227.sas7bdat..
没有12月24到26的,因为股市不开盘..
我是写好的macro去把数据都把给定时间范围的数据整理输出到一个csv file.之前的土方法是:
%LET alldate=20111222 20111223 20111227;
%DO i = 1 %to 3;
%LET date=%scan(&alldate,&i);
%LET filename=taq.ct._&date;
%dataprocess(file = &filename);
%END
我现在要做几年的数据,土方法就麻烦好多,要手动输入上千天的alldat... 阅读全帖 |
|
p****u 发帖数: 1940 | 7 俺想求人帮忙下载点东西。。。
erdport1, ermport1:
老板想让我想办法看看这两个数据库。
these are returns with returns of firms with similar size
不知道哪位好心的大侠能帮我下载一下。
/wrds/crsp/sasdata/a_indexes
erdport1.sas7bdat
ermport1.sas7bdat
然后我们可以用dropbox 或者用sugarsync的办法传给我。
我非常感激!送50个包子!
:) |
|
P****D 发帖数: 11146 | 8 没看懂。你的问题不是已经解决了?既然已经知道“发现这两个格式都不能导入HLM,
除非SPSS数据转化成sav后缀名的格式,或者SAS转化成sas transport后缀名的格式。
”,那就照做就是了啊。
如果你是手里只有.sps(SPSS没有这种后缀名,你看错了sys?)和.sas7bdat(SAS后
缀名)文件但不知道怎么转化的话。我假设你手里有SPSS和SAS软件。那么双击打开.
sas7bdat,然后File->Export Data->Next->有个下拉框可以选你要的格式,可以选
Excel或Tab Delimited File(我就不信有软件不支持这两种格式)-> Next->告诉SAS
你想把转换成的文件存放在哪里->确定,然后看到“完成”出来的时候就点完成。 |
|
S********a 发帖数: 359 | 9 我用简体中文已经读入了,但是出现俩个问题,第一,变量名是_col0 _col1 _col2...., 怎么能读入中文的变量名呢?第二,我打开生成的SAS文件(即后缀是.sas7bdat),凡是中文的部分都呈现的问号,即???,但是proc print呈现的是中文,我的电脑可以打中文和阅读中文,请教为啥和怎么让SAS文件(即.sas7bdat)也显示中文呢?万分感谢!!! |
|
h******e 发帖数: 1791 | 10 也许是encoding的问题,试试encoding = euc。
..., 怎么能读入中文的变量名呢?第二,我打开生成的SAS文件(即后缀是.sas7bdat)
,凡是中文的部分都呈现的问号,即???,但是proc print呈现的是中文,我的电脑
可以打中文和阅读中文,请教为啥和怎么让SAS文件(即.sas7bdat)也显示中文呢?万
分感谢!!! |
|
d*********d 发帖数: 239 | 11 请教:
SAS 用table editor 能生成.dat 格式吗? 发现生成的都是.sas7bdat格式。这个和.
dat有什么不同吗? 我试图用infile 语句貌似对.sas7bdat文件不可以。是这样吗?
我是弱爆初学者,请大虾们指导一下。
谢谢。 |
|
k*z 发帖数: 4704 | 12 我们公司因为法律的关系,必须把澳门的数据去掉用户名和地址,联系电话才能交道总
部。这样他们用SAS处理过以后的sasdata包含过去所有的数据 都存成一个 A.sas7bdat
,给我们。每天我们都要去copy这个数据从sharedrive上过来到local SAN。然后我们接
着用SAS Clean得到我们要用的数据. 其实就是在不断的做重复工作。有什么建议可以
用SQL 2012来简化这个过程么?
我们每天用batch copy过来,然后我用SSIS导入一次以后,再导入说存在同一个,
table,刚开始用SQL 2012,有达人能给点建议么? |
|
F****3 发帖数: 1504 | 13 不是坏事,是因为竞争对手也在服务器上。我比如run
sas XYZ_project.sas &
gzip ABC_data.sas7bdat &
别人就是到我是run什么project了。我开始不知道别人能看到我的process,知道昨天
一个cs的人到我家来我才知道,我的process全能被我竞争对手看到 |
|
w*z 发帖数: 71 | 14 S+ 6.0 (for Win) has a function importData() which supports many file types
including .csv, .dbf, .xl?, .sd2, .ssd01, .ssd04, .sas7bdat, .sd7, .sav, .por,
and lot more.
致
一 |
|
c**********n 发帖数: 80 | 15 我在网上下载的SAS 9.1.3 安装在D盘里,在编写程序的时候用infile 'd:\abc\efg.
sas7bdat' 语句
时log里面总是说文件不存在。(路径没有错);
另外用到mmddyy10. 的format的时候说找不到这个format,是不是少装了一些功能呢?
我目前把sas完全
安装了还是不行,是不是要另外找补丁?能麻烦告知在哪里能下载么?
十分感谢! |
|
s**c 发帖数: 1247 | 16 这是sas的data file
要装了sas才能打开 |
|
y*****t 发帖数: 1367 | 17 安装免费的SAS System Viewer也能打开,不过不能在Viewer下运行SAS程序~ |
|
j******g 发帖数: 25 | 18 %macro byyear(year=);
data interest;
set "C:\ResearchData\US_Interest_Data\interest.sas7bdat";
where year=&year.;
proc sort; by year month day;
proc expand data=interest out=interest method=step; var m1 m3 m6 m12;
请问大家 byyear(year=) 啥意思
proc expand 什么意思啊 |
|
D*******a 发帖数: 207 | 19
number
Just use colClass to read as "character", then you will have 007.
1. If you can not read other than "factor" or "character, this is because
you have non-numeric entries in this column. For example, "Missing", "-",
etc. Find it out and correct it.
2.You can't use as.numeric(factor) in this case. This function will return
the coded level (very dangerous! You will be burnt by this in the future, if
you are not careful). For example,
as.numeric(factor(c("a",2)))
[1] 2 1
You got 1674 because |
|
D*********2 发帖数: 535 | 20 Thanks a lot!!!!!
Yes, I do have missing values in the three numeric variables, denoted as "."
, Should I correct it in SAS before importing them into R, like recoded it
is "999"? Is it the common way to do this? Because I was thinking we may
need to avoid hard coding in SAS.
Besides, I doubt it is caused by missing value, here is the error message I
got after read.table
Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,
scan() expected 'a real', got '"117.200"'
Thanks |
|
|
D*******a 发帖数: 207 | 22
."
I
You can change the dot to NA, then R can recognize it as NA. 999 is not a
good idea, as later on you may confuse it with valid numbers.
Your R code complained maybe because you used quoted txt file. I guess your number is "117.200" (quoted by "") other than 117.200 (not quoted by ""). Take a look of your .csv file (using a text editor).
In my previous answer I answered your first choice too (csv). Did you try to read 007 as character? |
|
D*********2 发帖数: 535 | 23 Yes, it works when I use
> dat.corr <- read.csv(file="xxx.csv", colClasses=rep("factor", 4), T)
However, I did not notice, even use read.csv, it gave me "factor". Why?
I simply did import to .csv in SAS.
> dat.corr <- read.csv(file="xxx.csv", T)
> sapply(dat.corr, class)
Y X1 X2 X3
"integer" "factor" "factor" "factor"
Y is the one should be factor, say, "007". X1:X3 should be numeric.
Thanks again! |
|
s**c 发帖数: 1247 | 24 sometimes I used a fake observation at the first line
them delete it |
|
D******n 发帖数: 2836 | 25 for 1) u can easily convert it
data$v1<-sprintf("%03d",data$v1)
number |
|
D*******a 发帖数: 207 | 26
First change the dots to NA in the X1,X2,X3 columns. Then:
dat.corr <- read.csv(file="xxx.csv", colClass=c("character",rep("numeric",3)
), T) |
|
D*********2 发帖数: 535 | 27 Thanks, problem solved!
I really appreciate your help :-)
3) |
|
|
D*********2 发帖数: 535 | 29 Thanks. Although the problem is solved. I am still interested in this read.
ssd. I am so confused, would you please give me a hand?
I tried the example in the help document for windows,
read.ssd(file.path(sashome, "core", "sashelp"), "retail",
sascmd = file.path(sashome, "sas.exe"))
no problem, successfully imported.
But back to my case,
statdat <- "/Users/Dreamer1122/Documents/My SAS Files/9.2"
read.ssd(file.path(statdat), "dat_corr_03232010", sascmd = file.path(sashome
, "sas.exe |
|
D*********2 发帖数: 535 | 30 Thanks, works well for 1). |
|
P****D 发帖数: 11146 | 31 1. Did you specify sashome correctly?
2. I'd suggest you specify the full path for your dataset in the first file.
path option.
This read.ssd command works fine on my 32-bit XP with SAS 9.2. |
|
P****D 发帖数: 11146 | 32 Oh, and you do need to have full function SAS (SAS universal viewer will not
suffice) installed on your computer to make this read.ssd work. I don't
know if you can get it to work with WPS. |
|
S******y 发帖数: 1123 | 33 I am curious about how well SAS/IML studio is integrating with R. Has
anybody had experience with that?
Does it allow R to directly read in SAS data files (xx.sas7bdat) without
manually going through conversion via CSV format?
How large a R data frame can SAS/IML studio handle?
Can SAS and R call each other ‘s functions/PROCs?
Is SAS/IML is a separate product users have to purchase in addition to SAS/
STAT?
Thanks. |
|
S********a 发帖数: 359 | 34 比如通过data manipulate删除了一个raw dataset里的一些变量,从而生成了一个新的
dataset, 然后怎么把这个dataset从output window里输出,变成另一个raw dataset (
即后缀是.sas7bdat)?
包子答谢!! |
|
S********a 发帖数: 359 | 35 谢谢,能给个例子/code吗?data step怎么把work里的文件输出成.sas7bdat 文件? |
|
S********a 发帖数: 359 | 36 我还是没说明白,我在运行程序的时候生成了新的 dataset, 比如a.newdata, 然后我
想把这个newdata变成newdata.sas7bdat文件,不是excel或txt文件。
请支招。。。 |
|
s******r 发帖数: 1524 | 37 did not get it.
b and a.newdata are both sas7bdat file. the only problem is where it saved. b saved under your work directory and newdata saved on under libname a. You should check your lib setting. |
|
h******e 发帖数: 1791 | 38 你说得很明白,你的问题是不理解SAS的library和windows的文件夹的关系。实际上前者是后者在SAS里的名字,所以你用libname.datasetname可以让SAS在你指定的文件夹里生成一个datasetname.sas7bdat这个文件。 |
|
p********a 发帖数: 5352 | 39 That is SAS7bdat, not cat |
|
S******y 发帖数: 1123 | 40 I have written some (Shell + SAS sysparm ) batch scripts to view my
SAS data set on Unix.
For example --
If I have a SAS data set called - mytestdat.sas7bdat
I will type the following command on Unix -
> see mytestdat
then I will automatically get a file called _see.lst, which contains
PROC CONTENTS and PROC PRINT (top ten records) output.
Following the same logic, I have developed a number of scripts -
> freq 'mytestdat|loss_year'
to see freq by loss_year variable
> summary 'mytestdat|loss_year... 阅读全帖 |
|
f*******i 发帖数: 8492 | 41 是这样的,我已经有一个datasheet,homework10.sas7bdat
然后,其中的date1格式就是“21MAY2001:00:00:00”, 但这个不是numeric value,
而是character
所以我根据楼上说的,先把date1读写为numeric value的date2,再从中提取date部分
data homework10;
set class.homework10;
date2=input(date1,date16.);
format date2 date16.;
date3=datepart(date2);
format date3 date9.;
range=date3-'01JAN2001'dt;
run;
proc print data=homework10;
var date1 date2 date3 range;
run;
如果时间格式是“21MAY2001:00:00:00”, 那么datetime后面跟着的数字是应该取15,
16,17,还是18?
我现在无论取那个数,得到的date2,都是这种格式“21MAY01:00:00:00”,并... 阅读全帖 |
|
x**g 发帖数: 807 | 42 正在看一批数据,是SAS格式 (.sas7bdat),可是还带了一个同样文件名,不同后缀
名的文件(.trn)。请问这个.TRN文件是干什么用的阿?
在这批数据里还看到一个import的程序,是这样写的
%let dirnam = 'c:\folder';
%let trnnam = 'e:\folder\bbb010.trn';
libname dir &dirnam;
libname dirx xport &trnnam;
proc copy in=dirx out = dir;
run;
谁能帮忙解释一下阿? |
|
D******n 发帖数: 2836 | 43 i googled and found sas7bdat and Hmisc.
Which one is good?
Bad thing about R is too many packages and none is good enough. |
|
i*****y 发帖数: 188 | 44 sas7bdat does not require SAS in the background;
but it did not work a lot of times depending on your data
I do not think it is good enough |
|
P****D 发帖数: 11146 | 45 The txt you mentioned: comma-delimited file.
SAS: the extension name is SAS7bdat. |
|
g******d 发帖数: 231 | 46 我现在遇到个情况,就是想把SAS数据.sas7bdat转换成.dbf文件,结果在64bit的环境
下生成的都是乱码。如果在32bit的环境下(操作系统兼stat transfer 32bit)转换的
结果就正常了。
请问这是怎么回事?是不是有些设置我需要注意?谢谢! |
|
w*****m 发帖数: 414 | 47 多谢了。
BTW,
pipe function only works for txt.gz file. |
|
|
d******9 发帖数: 404 | 49 Hehe... I happen to know it.
filename AAA SASZIPAM 'c:\your path\filename.zip';
Then you can use data step or proc import to read in from ZIP file directly.
Baozi, please |
|
|