I was trying to inquiry data from TAQ, daily trade database. In SAS, I did the following but sas complained that, "Library does not exist." I am sure that the path is correct.
%let wrds = wrds.wharton.upenn.edu 4016;options comamid = TCP remote=WRDS;
signon username=_prompt_;
*************************************************************************;
libname ct'/wrds/nyse/sasdata/taqms/ct';
rsubmit;
The log said:
NOTE: Libname CT refers to the same physical library as TAQMSE.
WARNING: Library CT does not exist.
NOTE: Libref CT was successfully assigned as follows:
Engine: V9
Physical Name: C:\wrds\nyse\sasdata\taqms\ct
rsubmit;
NOTE: Remote submit to WRDS commencing.
But when I first login into the wrds server, I saw the path, and the first engine gives the path of the library which I wanted to use. What did I do wrong in order to set up the library?
NOTE: Libref TAQMSEC was successfully assigned as follows:
Levels: 5
Engine(1): V9
Physical Name(1): /wrds/nyse/sasdata/taqms/ct
Engine(2): V9
Physical Name(2): /wrds/nyse/sasdata/taqms/cq
It appears as though you are trying to reference a remote library in your local session. Try running the following AFTER the remote library has been assigned in the rsubmit; block (so, after the endrsubmit; statement):
libname CT (TAQMSEC) server=WRDS;
Related
This is a follow up question to a previous post. I am trying to store a macro in a catalog as outlined by these articles, in addition to the resources cited in my original post:
PROC CATALOG, the Wish Book SASĀ® Procedure
Ways to Store Macro Source Codes and How to Retrieve Them
Creating a Stored Macro Facility in Ten Minutes
Here is what I have done so far:
I have created a directory "C:\myMacros." First, I create a program called "HelloWorld.sas" which contains the following code:
/* HelloWorld.sas */
option mstored sasmstore=mymacros;
libname myMacros 'C:\myMacros';
%macro HelloWorld() / store source;
data _null_;
put "Hello, World!";
run;
%mend;
The code executes with the following log entry:
1 option mstored sasmstore=mymacros;
2 libname myMacros 'C:\myMacros';
NOTE: Libref MYMACROS was successfully assigned as follows:
Engine: V9
Physical Name: C:\myMacros
3
4 %macro HelloWorld() / store source;
5 data _null_;
6 put "Hello, World!";
7 run;
8 %mend;
Within the SAS File Explorer, the Active Library "Mymacros" has been created in which resides catalog named "Sasmacr". Checking within Windows Explorer, I see that "C:\myMacros\sasmacr.sas7bcat" has been created. In the SAS File Explorer, I click on the "Sasmacr" catalog and find "Helloworld" inside. When I double click on it, I get message box saying,
No default action for the Macro data type.
Therefore, I conclude that the macro has been compiled and stored in the "Sasmacr" catalog. I close out of SAS to clear all memory.
Now, I try to call the macro. I open a new SAS session and create a new program titled "CallHelloWorld1.sas" which contains the following code:
/* CallHelloWorld1.sas */
libname myMacros 'C:\myMacros';
filename myCat catalog 'mymacros.sasmacr.helloworld.source';
%include myCat;
%HelloWorld();
This generates an error at the %include statement.
1 /* CallHelloWorld1.sas */
2 libname myMacros 'C:\myMacros';
NOTE: Libref MYMACROS was successfully assigned as follows:
Engine: V9
Physical Name: C:\myMacros
3 filename myCat catalog 'mymacros.sasmacr.helloworld.source';
4 %include myCat;
ERROR: Physical file does not exist, SOURCE .
ERROR: Cannot open %INCLUDE file MYCAT.
5
6 %HelloWorld();
-
180
WARNING: Apparent invocation of macro HELLOWORLD not resolved.
ERROR 180-322: Statement is not valid or it is used out of proper order.
The error claims that the physical file doesn't exist, which contradicts my observation of it above. So, I conclude that I am calling it incorrectly. According to FILENAME Statement, CATALOG Access Method, a SAS four part name consists of library.catalog.entry.entrytype. My statement consists of
The library: myMacros as defined by libname myMacros 'C:\myMacros';
The catalog: sasmacr
The entry: helloworld
The type: source
That is, mymacros.sasmacr.helloworld.source. There must be an error in here, but I cannot fathom what it is.
To try another approach, again I close out of SAS to clear the memory. I create "CallHelloWorld2.sas" which contains the following code:
/* CallHelloWorld2.sas */
libname myMacros 'C:\myMacros';
filename myCat catalog 'mymacros.sasmacr';
%include myCat(HelloWorld);
%HelloWorld();
This too produces an error at the %include line:
1 /* CallHelloWorld2.sas */
2 libname myMacros 'C:\myMacros';
NOTE: Libref MYMACROS was successfully assigned as follows:
Engine: V9
Physical Name: C:\myMacros
3 filename myCat catalog 'mymacros.sasmacr';
4 %include myCat(HelloWorld);
ERROR: Entry HELLOWORLD.SOURCE not found in catalog MYMACROS.SASMACR.
ERROR: Cannot %INCLUDE member HelloWorld in the aggregate MYCAT.
ERROR: Entry HELLOWORLD.SOURCE not found in catalog MYMACROS.SASMACR.
ERROR: Cannot %INCLUDE member HelloWorld in the aggregate MYCAT.
5
6 %HelloWorld();
-
180
WARNING: Apparent invocation of macro HELLOWORLD not resolved.
ERROR 180-322: Statement is not valid or it is used out of proper order.
It appears that either my macro has not been stored properly or that I am calling it incorrectly. However, the resources are woefully inadequate. Please help!
libname myMacros 'C:\temp';
option mstored sasmstore=mymacros;
%helloWorld()
That's all you need to do - remind SAS where you are pointing things and then run the macro. You don't need to %include anything.
I am learning the RSUBMIT newly and I discovered that when I do a rsubmit with data statement, it doesnt take a local libray in the set statement?
How can we process this?
my code
signon server;
rsubmit;
data x;
set loca.mydata ;run;
endrsubmit;
this throws error saying
ERROR: Libref loca is not assigned.
should the set statement dataset also be present in the remote library?
When you rsubmit some code you're basically sending it off elsewhere to get processed meaning none of your local assignments are present on the remote server.
One way to use your "LOCA" library would be to reassign it once you've r-submitted the code:
signon server;
rsubmit;
libname LOCA "<path here>";
data x;
set loca.mydata; run;
endrsubmit;
A second method would be to share the library between the sessions using inheritlib:
signon server;
rsubmit inheritlib=(LOCA=R_LOCA);
data x;
set R_LOCA.mydata; run;
endrsubmit;
In the both cases you'll also need to retrieve your dataset "WORK.X" from the remote server. Both methods I've shown will also allow you to do this.
I would like to do proc import for xlsm data.
proc import
out = outdata
datafile = "C:\User\Desktop\data.xlsm"
dbms = excelcs replace;
sheet = "SheetA";
run;
The error message is:
ERROR: CLI error trying to establish connection: [Microsoft][ODBC Excel Driver]General error
Unable to open registry key Temporary (volatile) Ace DSN for process 0x4058 Thread 0x3dc0
DBC 0x2c1780c Excel'.
ERROR: Error in the LIBNAME statement
When i use dmbs=excel instead; i got following error msg:
ERROR: Connect: Class not registered
ERROR: Error in the LIBNAME statement.
I think it should have something to do with PC file server under 64-bit system. A quick solution (which I usually use) is to first save your .xlsm file in .csv format and then do SAS import.
I've just learned PROC FCMP from this page:
http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a003181727.htm
The function works fine locally, so I wonder if I can use this proc remotely. In my point of view, as long as I change the output library for this function, it could be used in remote server. Here's my code:
proc fcmp outlib=rwork.funcs.trial;
function study_day2(intervention_date, event_date);
n = event_date - intervention_date;
if n >= 0 then
n = n + 1;
return (n);
endsub;
options cmplib=rwork.funcs;
run;
rsubmit;
data _null_;
start = '15Feb2008'd;
today = '27Mar2008'd;
sd = study_day2(start, today);
put sd=;
run;
endrsubmit;
For the 1st section, I get a notice that the function has been saved in the RWORK library:
NOTE: Function study_day2 saved to rwork.funcs.trial.
However after running the 2nd section, I get this error:
ERROR 68-185: The function STUDY_DAY2 is unknown, or cannot be
accessed.
Is there a way to fix this issue? Thanks!
Assuming you want to program this way (compile the function on your local machine and run it remotely), and you have a machine connected over SAS/CONNECT that is the same operating system and bitness (64/32 bit) as your local machine, you need to run options cmplib=rwork.funcs; in your rsubmit (except you likely need to change it, assuming rwork refers to your remote work directory, to options cmplib=work.funcs;).
rsubmit;
options cmplib=work.funcs;
data _null_;
start = '15Feb2008'd;
today = '27Mar2008'd;
sd = study_day2(start, today);
put sd=;
run;
endrsubmit;
That option isn't for proc fcmp, as you seem to think based on where you located it. It is telling SAS where to look when using the function. (The outlib option in proc fcmp is what is needed to store it there.)
If your remote server is a different OS or bitness than your local machine, you can't do this, and would need to put the entire section of code in the rsubmit.
I have SAS code that reads my password from an external .txtfile and establishes connection with odbc . When i run the following code in SAS, it works fine
filename pw "C:/xxxx";
data _NULL_ ;
infile pw ;
input pw : $50. ;
call symputx('pwd',pwd);
run;
libname xxx odbc user=myUser password=&pwd. dsn=myDsn schema=mySchema;
proc sql;
connect to xxx(dsn=myDsn user=myUser password=&pwd.);
However when I create a batch file to run it from Windows task scheduler or run it from SAS Enterprise Guide I get Apparent symbolic reference PWD not resolved
Why is this happening ? How to deal with this issue ?
Because your call symputx is not correctly defining it, at least based on the code you pasted.
data _NULL_ ;
infile pw ;
input pw : $50. ;
call symputx('pwd',pw);
run;
That would be the correct syntax (or change the input statement to read pwd). Look at your datastep's log, it should have a warning pwd was uninitialized.
If you pasted the code properly, I would still look to your data step's log, and see if any rows were processed. mjsqu may be correct in that you may not have visibility to the directory (if this is on a server and you're not accessing a server-visible directory), or some other issue may present as a result of you being in a different environment.
You have a typo. My guess is that your original variable was named pwd and you tested your code and it ran fine and then you renamed it. If you close your sas session and try rerunning it I bet it fails.
Try changing to this:
filename pw "C:/xxxx";
data _NULL_ ;
infile pw ;
input pw : $50. ;
call symputx('pwd',pw);
run;