由买买提看人间百态

topics

全部话题 - 话题: libname
首页 上页 1 2 3 (共3页)
a****t
发帖数: 1007
1
来自主题: Statistics版 - SAS model 一个简单的问题。
一个简单的程序,老做不出来各个因素的Interaction effect。不知道为什么。请点拨
一下。谢谢。
libname mysas 'D:\mysas';
data mysas.beet;
do harvest=1 to 2;
do rep=1 to 6;
do variety=1 to 6;
input col prod @@;
output;
end;
end;
end;
cards;
3 19.1 6 18.3 5 19.6 1 18.6 2 18.2 4 18.5
6 18.1 2 19.5 4 17.6 3 18.7 1 18.7 5 19.9
1 18.1 5 20.2 6 18.5 4 20.1 3 19.6 2 19.2
2 19.1 3 18.8 1 18.7 5 20.2 4 18.6 6 18.5
4 17.5 1 18.1 2 18.7 6 18.2 5 20.4 3 18.5
5 17.7 4 1... 阅读全帖
b*****o
发帖数: 817
2
没太看懂。
到底上面的例子中in0和in1能同时使用么?
D******n
发帖数: 2836
3
nothing will be written and hence nothing will be overwritten.
l***a
发帖数: 12410
4
同时多少个都行
P****D
发帖数: 11146
c*****t
发帖数: 1712
6
你自己test下不就行了?
A*******s
发帖数: 3942
7
来自主题: Statistics版 - SAS how to change variables' name
%macro add_prefix(lib=, table=, prefix=);
proc sql noprint;
select cats(name, '=', substr(cats(upcase("&prefix"), "_", name), 1, 32)
) into: rename_list separated by " "
from dictionary.columns
where libname=upcase("&lib") and memname=upcase("&table")
;
quit;
data &lib..prfx_&table;
set &lib..&table;
rename &rename_list ;
run;
%mend;
m****r
发帖数: 202
8
来自主题: Statistics版 - SAS how to change variables' name
%macro add_suffix(lib=, table=, suffix=);
proc sql noprint;
select cats(name, '=',name, "_", substr(cats(upcase("&suffix")), 1, 32)
) into: rename_list separated by " "
from dictionary.columns
where libname=upcase("&lib") and memname=upcase("&table")
;
quit;
data &lib..prfx_&table;
set &lib..&table;
rename &rename_list ;
run;
%mend;
It gives me what I expect. Thanks all.
D******n
发帖数: 2836
9
来自主题: Statistics版 - Unix/Linux scripts for SAS
proc print. lol
WORK directory is supposed to be temporary and files there will be wiped out
once the sas job is done unless there are some errors incurred by your
steps.
You can try sth like this. just toggle between %debug(1) and %debug(0) you
can opt to save your temp data sets to the current folder.
============================================================>
libname newwork '.';
%macro debug(flag);
%global work;
%if &flag eq 1 %then %let work=newwork.;
%else %let wo... 阅读全帖
k*******a
发帖数: 772
10
来自主题: Statistics版 - SAS中FORMAT问题求教
试试这个macro, 他把你所有数值型变量转化为对应的format,如果这个obs有至少一个'NA',
那么就设
置flag=1,否者flag=0
%macro flag(lib=, data=, out=);
proc sql;
select name, format, count(*) into
:var separated by ' ', :fmt separated by ' ', :n
from sashelp.vcolumn
where upcase(libname)=upcase("&lib") and
upcase(memname)=upcase("&data") and
type='num' and
format ne '';
quit;
data &out;
set &lib..&data;
flag=0;
%do i=1 %to &n;
if put(%scan(&var,&i), %scan(&fmt, &i, "' '")) = 'NA'
... 阅读全帖
c******5
发帖数: 22
11
还是没有回帖,估计是我叙述的不清楚吧。我有一个sas data set,它附带有3个
format文件名字叫‘formats'。我把这三个format 文件各取名字叫'formats_1' '
formats_2',‘formats_3', 然后和我的sas data set一起放在了我指定的library '
proj1'中。用下面的语句给了format文件的位置(libname 已经指定了proj1):
options fmtsearch =(proj1);/*指定format位置*/
读了一部分format,但也得到了下面的error:
'Format ... not found or couldn't be loaded for variable ...'。
然后我又是试着改回原来的名字 ‘formats', 把3个format文件放在了3个地方,'
work','sasuser',和一个自己建的library-proj1:
options fmtsearch =(Work Sasuser proj1)。 读入了更多的format,但还有一样的
error message。
我... 阅读全帖
z**********i
发帖数: 12276
12
放在同一个FOLDER.
LIBNAME AA "\YOUR FORMATS LOCATION";
OPTIONS FMTSEARCH=(AA.FORMAT1, AA.FORMAT2, AA.FORMAT3);
c******5
发帖数: 22
13
哦,是不是读数据的时候还要调用format? 谢谢你这么快答复,下面是log文件:
273 LIBNAME proj1 '...';
NOTE: Libref PROJ1 was successfully assigned as follows:
Engine: V9
Physical Name: ...
274
275 OPTIONS FMTSEARCH=(proj1.formats_1, proj1.formats_2, proj1.formats_3);
277 /*2) Read the sas datafiles*/
278 Proc print data=proj1.test;
279 Run;
ERROR: Format ... not found or couldn't be loaded for variable ...
ERROR: Format ... not found or couldn't be loaded for variable ...
ERROR: Format ... not found or c... 阅读全帖
n******e
发帖数: 476
14
来自主题: Statistics版 - sas 9.2 graphics
你们有什么好的 resources 学习么?我看了一本教材和网上搜来的一些 sample,怎么
都用他们自己的特有数据,让我没有他们的数据就没法 run sample codes 啊。
郁闷.....以前 training 发了一本欧洲某培训公司出的书,内容还挺好的,就是数据
我找不来,书里从头到尾也没说数据哪里来的。不过 libname 就是他们公司名字,应
该是他们自己的数据吧。真是看得干瞪眼
谁有用 SAS 自带数据的教材或者 samples?
d**********o
发帖数: 1321
15
来自主题: Statistics版 - 请教 sas functions
再问一下:
proc contents data=dqa.ni_adjustment_factor; run;
ERROR: File DQA.NI_ADJUSTMENT_FACTOR.DATA does not exist.
保留版本work.ni_adjustment_factor_200901 (&per1=200901)是可以manipulate的。repeated run of "%varname;" will overwrite work.ni_adjustment_factor_200901.
而dqa libname中明明看见数据在,而且可以打开数据表,为什么用code就不能access呢?
而且dqa中存几个同样名字dqa.ni_adjustment_factor同样大小的表(repeated run of %varname;)sas并不识别?
dqa.ni_adjustment_factor是这么建的:
%macro varname;
data _null_;
set varname end=last;
call symput... 阅读全帖
p********a
发帖数: 5352
16
Assume you are using Windows system. Here is an example
%let dir=c:\test;
libname dict "&dir.";
%sysexec cd &dir; %sysexec dir * /b/o:n >flist;
data indexfile;
length filen $200 ;
infile "&dir./flist" length=reclen;
input filen $varying256. reclen;
run;
data indexfile;
set indexfile;
length type $5;
dataname=upcase(scan(filen,1,'.'));
if find(dataname,'RXCLAIMS') then type='RX';
if find(dataname,'MEDCLAIMS') then type='MED';
if find(dataname,'DM_MEMBER') then type='MBR';
if find(dataname,'ENROL... 阅读全帖
k*******a
发帖数: 772
17
来自主题: Statistics版 - ask for help (urgent): A SAS question
写了隔macro你试试看
%macro rename(lib=,data=);
proc sql;
select strip(name)||'='||compress(name,'_') into :rename separated by ' '
from sashelp.vcolumn
where upcase(libname)=upcase("&lib") and upcase(memname)=upcase("&data");
quit;
data new;
set &lib..&data;
rename &rename;
run;
%mend;
p***r
发帖数: 920
18
来自主题: Statistics版 - Import XLSX 格式的EXCEL文件问题
proc import
libname
or change xlsx to csv
...
J********J
发帖数: 571
19
来自主题: Statistics版 - Import XLSX 格式的EXCEL文件问题
Thanks for the reply.
Is there anyway that I can change XLSX to CSV in the program? I think I
would have to import the XLSX file first, then I can change it to CSV.
LIBNAME won't work for XLSX, as far as the info I can google.
l***i
发帖数: 8
20
来自主题: Statistics版 - SAS BASE Questions
The following SAS program is submitted:
data test;
set sasuser.employees;
if 2 le years_service le 10 then amount=1000;
else if years_service gt 10 then amount=2000;
else amount=0;
amount_per_year=years_service/amount;
run;
Which one of the following values does the variable Amount_per_year contain
if an employee has been with the company for one year?
A.0
B. 1000
C.2000
D.(missing numeric value)
Why the answer is C? I can not understand. Can any body explain to me why?
Thanks!
#################... 阅读全帖
d******9
发帖数: 404
21
来自主题: Statistics版 - SAS help : Proc dataset
Use dictionary or SAS Help dataset, for example:
proc sql;
create table Z as
select *
from sashelp.vmember
where upcase(libname)='WORK';
quit;
o*******w
发帖数: 2310
22
来自主题: Statistics版 - 这sas BASE 考试很坑爹..
The contents of the SAS data set named PERM.STUDENTS are listed below:
name age
Alfred 14
Alice 13
Barbara 13
Carol 14
The following SAS program is submitted using the PERM.STUDENTS data set as
input:
libname perm 'SAS-data-library';
data students;
set perm.students;
file 'file-specification';
put name $15. @5 age 2.;
run;
Which one of the following represents the values written to the output raw
data file?
A. --------10-------20-------30
Alfred 14
Alice 13
Barbara 13
Carol 14
B. --------10-----... 阅读全帖
c*****1
发帖数: 131
23
来自主题: Statistics版 - 二个包子答谢解决问题的回贴
check if you have used libname to define the directory where the dataset
located.
o*******w
发帖数: 2310
24
来自主题: Statistics版 - 二个包子答谢解决问题的回贴
oh, this will not work this is for program..
you may need the libname first, but I don't think you did not do it.
p*****e
发帖数: 290
25
来自主题: Statistics版 - 有谁对SAS和R都懂得吗?
如题。有一个很蠢的问题请教一下,多谢了。
下面是SAS连接到SQL的语句,
libname res oledb user=XXX password=XXXXXX dsn=AAA
provider=sqloledb properties=('initial catalog'=research) schema=dbo;
现在我要用R实现同样的连接到这个SQL,我读了RODBC的package介绍,用了下面语句,
但是怎么都不行。请问该怎么修改才能像上面SAS语句一样连到SQL上,多谢了!
conn <- odbcConnect("AAA", uid="XXX", pwd="XXXXXX")
d******9
发帖数: 404
26
来自主题: Statistics版 - sas question!!!
Or use macro to do it. Below codes works well, tested with few sample
datasets.
options mprint symbolgen;
data A_201201;
A=225;
run;
data A_201207;
A=226;
run;
data A_201205;
A=338;
run;
data R_201207;
A=338;
run;
data B_201279;
A=551;
run;
proc sql;
select memname into : tables separated by ' '
from sashelp.vtable
where libname='WORK' and upcase(substr(memname, 1,1))='A';
quit;
data combine;
set &tables;
run;
=============================
LOG:

45 data combine;
SYMBOLGEN: Macro ... 阅读全帖
M*********t
发帖数: 250
27
来自主题: Statistics版 - 帮我看看如何导入.dat file into sas吧
我一直都这么做的,不知道怎么的今天code就不行了。。。
libname trial 'C:';
proc import datafile='C:\trial1.csv'
out=trial.item dbms=csv replace;
getnames=yes;
run;
error is "Physical file does not exist"...
但是trial这个路径下有trial1.dat file 啊
k*****u
发帖数: 1688
28
来自主题: Statistics版 - 请教个SAS ORACLE DATABASE的问题
LIBNAME oralib ORACLE PATH=alien USER=scott PASSWORD=”{sas001}dGlnXYZ=”
schema=SCOTT;
然后oracle的那些table就类似于sas的data sets用了
http://support.sas.com/techsup/technote/ts771.pdf
n****e
发帖数: 226
29
proc catalog catalog=LIBNAME.sasmacr;
contents;
run;
something like that?
j******o
发帖数: 127
30
来自主题: Statistics版 - How to import several excel files together?
昨天刚写了几段code,不过是对csv的,请你改一下用在Excel文件上吧。中间有些地方
可能不太完善(比如文件名不能有空格等),欢迎改进及简化。
----------------------------------------------------------------
libname backup "C:\Documents and Settings\Ying\Desktop\Test";
filename blah pipe 'dir "C:\Documents and Settings\Ying\Desktop\Test\*.csv"
';
data dirlist;
infile blah truncover lrecl=200;
input line $200. ;
if upcase(substr(line, 1, 9))='DIRECTORY' then call symput('direc', trim
(substr(line, 14, length(line))));
if input(substr(line,1,10), ??... 阅读全帖
s******r
发帖数: 1524
31
大包子 pls.
%macro test;
proc sql;
create table var_ls as select distinct name from dictionary.columns
where libname='WORK' and memname='TEST' and upcase(name) ne 'ID';quit;run;
data _null_;set var_ls;
call symput(cats('var',_n_),name);
call symput('cnt',_n_);
run;
proc sql;
create table test2 as
select id
%do i = 1 %to &cnt;
,max(&&var&i) as &&var&i
%end;
from test
group by id;quit;run;
%mend;
%test;

but
o****o
发帖数: 8077
32
凑个热闹,给个比较冗长但是通用的解法
data test;
input id $1 v1 3 v2 $5-6 v3 8 v4 $10-11;
cards;
a 1 x2 .
a . 3
a . . x4
b 1 x2 .
b . 3
b . . x4
;
run;
proc sql noprint;
select
case
when(type='char') then cat('length ', compress(name), ' $ ',
length, ';')
else cat('length ', compress(name), ' ', length, ';')
end
into :varlist separated by ' '
from sashelp.vcolumn
where libname='WORK' and memname='TEST'
;
quit;
%put... 阅读全帖
k*******a
发帖数: 772
33
可以用 SAS 的dictionary来找出data有什么variable
data test;
input var1 $ var2 $;
datalines;
3.4 5
4.55 5.3
4 3.444
;
run;
proc sql noprint;
select strip(name)||"_n=input("||strip(name)||",best12.)" into :convert
separated by ";"
from sashelp.vcolumn
where libname="WORK" and upcase(memname)="TEST";
quit;
data test1;
set test;
&convert;
run;
t**s
发帖数: 156
34
如果知道有多少variable需要转换,也可以用下面的方法.
假定有100个variable
Data test1;
Set test;
Array allchar(*) _char_;
Array newvar(*) newvar1 - newvar100;
Do i=1 to dim(allchar);
newvar(i)=Input(allchar(i), best.);
End;
Run;
如果不知道, 先找出来
proc sql noprint;
select count(*) into:cnt from sashelp.vcolumn
where libname="WORK" and upcase(memname)="TEST" and upcase(type=)"CHAR";
quit;
Data test1;
Set test;
Array allchar(*) _char_;
Array newvar(*) newvar1 - newvar&cnt;
... 阅读全帖
k**********a
发帖数: 255
35
来自主题: Statistics版 - 求助 SAS 一个error 老改不对
3222 libname sw 'C:\Users\given\Desktop\sw';
NOTE: Libref SW was successfully assigned as follows:
Engine: V9
Physical Name: C:\Users\given\Desktop\sw
3223 proc format lib=sw;
3224 value $itemfmt
3225 'C'='Cassette'
3226 'R'='Radio'
3227 'T'='Television';
NOTE: Format $ITEMFMT is already on the library.
NOTE: Format $ITEMFMT has been written to SW.FORMATS.
3228 run;
NOTE: PROCEDURE FORMAT used (Total process time):
real time ... 阅读全帖
h***x
发帖数: 586
36
libname clib "d:";
data clib.new;
set old;
run;
i******r
发帖数: 861
37
来自主题: Statistics版 - 请教SAS中libname 的一个问题
Are you sure that you do have the fold: C:\Research\Data ?
if you don't have this fold, you will have trouble.
Your code works for me.
w**p
发帖数: 4080
38
来自主题: Statistics版 - 请教SAS中libname 的一个问题
你确认你的桌面地址是这个么?
P****D
发帖数: 11146
39
来自主题: Statistics版 - 请教SAS中libname 的一个问题
错误提示说得很清楚了啊,楼主没有那个folder的privilege。不是code写得不对。
强烈建议不要跟它较劲,直接换一个文件夹。Windows下privilege的控制就是屎。
B******y
发帖数: 9065
40
来自主题: Statistics版 - 请教SAS中libname 的一个问题
你如果用的是公司的电脑,很多路径可能已经被IT设置为非法了。至少我的公司电脑是
绝对不会让我用到\User的路径的。
d******9
发帖数: 404
41
来自主题: Statistics版 - SAS MACRO question (包子求教重金酬谢)
If you do NOT have so many variables, you can rename the variables manually,
the below MACRO will work.
Please send me your BAOZI, thank you.
-------------------------------------------------------------
libname A 'your physical path';
****Use SAS MACRO to read in external CSV files from storage library.****;
filename Raw 'your physical path';
data AAA (drop=RC);
length Memname In_Name Out_Name $30;
Did=dopen("Raw");
if did> 0 then do;
Num=dnum(did);
do J=1 to Num;
Memname=dread(did, J);
In_Na... 阅读全帖
a*z
发帖数: 294
42
来自主题: Statistics版 - rggobi on windows 7 error
I would appreciate any help on my issue.
I have R 2.15.2 (32 bit and 64 bit) on a windows 7 ultimate (64 bit system).
I have RGtK2 package installed and updated.
I installed GGOBI (2.1.8, and later changed to 2.1.9) installed on C: drive.
I have gtk+-bundle_2.22.1-20101227_win32 downloaded and unzipped (7 zip) in
C: drive. I set the environment variables in path (c:\ggobi; c:\gtk\bin)
Then I installed rggobi package from CRAN. When I tried to load the package,
I got a popup window saying an erro... 阅读全帖
A*****a
发帖数: 1091
43
来自主题: Statistics版 - 求帮助:excel数据转csv和sas的读取
试了,还是不行,错误显示为:
ERROR: Connect: Class not registered
ERROR: Error in the LIBNAME statement.
Connection Failed. See log for details.
c**********e
发帖数: 2007
44
来自主题: Statistics版 - proc export to Excel: can not read it!
I use the following code to tranform a SAS dataset an Excel file on Unix.
libname myfolder '/abcd/efgh/ijkl';
proc export DBMS=XLS
data=myfolder.mydata
outfile="/abcd/efgh/ijkl/myfile.xls"
replace;
run;
quit;
But my Excel file can not be opened. Anybody knows how to solve it?
The error message:
"Excel found unreadable contents in 'myfile.xls'.
Do you want to recover the contents of this workbook?
If you trust the source of this workbook, click Yes."
l*****o
发帖数: 61
45
来自主题: Statistics版 - "Failed to connect to the server" SAS 9.4
新装了SAS9.4。用proc import to import excel file to 撒施.可是以前好好的程序
现在老是出"failed to connect to the server" error。 这是怎么回事啊?难道还象
SAS9.3那样子要单独装PC file server吗?
libname mylib "c:saslib";
proc import datafile='C:FMData_MMST2012.xlsx'
out=mylib.FM2012
dbms=excelcs replace;
sheet='FApp';
run;
j********t
发帖数: 201
46
来自主题: Statistics版 - 请教:SAS
There are two ways to do so:
1) as the other reply said, you save your data in a permanent library using
libname statement.
2) You can also find the temporary folder where work is located with the
following statement:
%put %sysfunc(getoption(work));
then you can use system command to move the files into a permanent location.
1) is commonly used.
2) is rarely used. It seems to take an "unnecessary" lengthy road. However
, when you want to use system commands that are outside of SAS session, 2)
... 阅读全帖
z********8
发帖数: 172
47
来自主题: Statistics版 - April 22/ 2014 SAS BASE PASS
我今天过了SAS BASE, 没有SAS经验,我是从版上拿的资料,所以想回馈。。。。
不过我现在觉得应该很少有人过不了base的
Anyway
贴上来希望对后来的同学有利,也为自己攒点人品
很多70题上面的,我能记住的都写出来, 64题,全部选择题,也没有填空
1(选项变了), 3, 4, 5, 7, 10, 11, 12 (JAN, FEB, MAR变成其他的,题目意思没变)
, 14, 15, 17, 18(变了), 19, 20 , 21,
23(sasdatafolder), 24, 25, 26, 27, 28, 30, 31, 33, 34, 35, 36, 40, 42, 45
, 46, 47, 49, 50, 51, 52, 53, 54, 56, 59, 60, 61 (变形),
63, 65, 67, 69, 70(问法变)
explanation:
1 ) 两个地方 insert code, 选项变了,变成分开问, 答案还是Gender
12) JAN, FEB, MAR 变成 item1, item2, item3, 选项也随之变了,但是意思不变... 阅读全帖
f***1
发帖数: 168
48
来自主题: Statistics版 - SAS学习的问题
把书看一遍,就干脆就做一个完整的小project吧。

data entry (proc sql, data step, proc import, 'libname' )开始,
-> data cleaning,
-> data analysis (各种proc )
-> report (proc report, proc gplot)
这样做完一个下来,基本上也就大致上手了。用了SAS好几年,觉得上手快,记忆难。
记不住的写到blog里头,方便日后自己翻翻。
c******y
发帖数: 3269
49
来自主题: Statistics版 - PROC SQL运行速度问题.
You are right about "需要把所有的数据都带到服务器或者本地" if it is SAS
implicit SQL-passthrough, in the means of libname, without in-database
processing.
To resolve the issue, there are several approaches.
1. views/stored procedures as you mentioned, which requires additional
maintenance and only fits for "frequently-used" joins.
2. implicit SQL-passthrough with in-database processing, which requires
knowledge on additional SAS syntax, and has a limitation on the usage.
3. explicit SQL-passthrough, which only pa... 阅读全帖
S****M
发帖数: 2198
50
来自主题: Statistics版 - PROC SQL运行速度问题.
我司平时用Teradata,但在SAS里还是用explicit pass-through最多。这样SQL在SQL
Assistant里写好debug完就能直接在SAS里跑。Explicit的问题(或许我孤陋寡闻)是
没法上传数据,这时候就只能用libname了。
首页 上页 1 2 3 (共3页)