SAS proc import xlsm files - sas

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.

Related

Why is TIMEOUT= argument not recognized within SAS PROC HTTP?

I'm trying to account for missing files at a specific URL. For example, running PROC HTTP to get the following Excel file https://www2.census.gov/programs-surveys/cps/tables/time-series/historical-poverty-thresholds/thresh17.xls runs without timing out, eventually returning a 304 code. The SAS documentation clearly lists TIMEOUT= as an optional argument, but when I try to use it I get a syntax error:
ERROR 22-322: Syntax error, expecting one of the following: ;, AUTH_ANY, AUTH_BASIC, AUTH_NEGOTIATE, AUTH_NONE, AUTH_NTLM, CLEAR_CACHE, CLEAR_CONN_CACHE, CLEAR_COOKIES, CT, EXPECT_100_CONTINUE,
FOLLOWLOC, HEADERIN, HEADEROUT, HEADEROUT_OVERWRITE, HTTP_TOKENAUTH, IN, METHOD, NOFOLLOW, NOFOLLOWLOC, NO_CONN_CACHE, NO_COOKIES, OUT, PROXYHOST, PROXYPASSWORD, PROXYPORT,
PROXYUSERNAME, PROXY_AUTH_BASIC, PROXY_AUTH_NEGOTIATE, PROXY_AUTH_NONE, PROXY_AUTH_NTLM, URL, VERBOSE, WEBAUTHDOMAIN, WEBPASSWORD, WEBUSERNAME.
ERROR 202-322: The option or parameter is not recognized and will be ignored.
Here is my code:
filename resp "C:\response";
proc http
url="https://www2.census.gov/programs-surveys/cps/tables/time-series/historical-poverty-thresholds/thresh17.xls";
method="GET"
out=resp
TIMEOUT=5;
run;
Is there a different way to account for timeout issues within SAS?
Most likely you are not running SAS version 9.4M5.
The 9.4 What's new documentation states in 9.4M5 (September 2017)
PROC HTTP adds a DEBUG statement, the OAUTH_BEARER= procedure option and TIMEOUT= procedure option, and response status macro variables.

SAS data step error "too long for buffer"

I am just trying to load a SAS file someone else sent. I can open the dataset by just clicking on it and I can run proc contents. However, when I tried to copy the data to the work library, or run some summary statistics, this error message occurred:
ERROR: An internal error has occurred while reading a compressed file.
Please call your SAS Site Representative and report the
following: compress offset = 330 , de-compress offset = 320 , compress buf = "" .
ERROR: Record in file lib1.file_name.DATA is too
long for buffer.
I tried to increase the bufsize options bufsize=32768 or use
compress = Yes, but neither helped. Any suggestions?
It seems your dataset is damaged.
So you can try to repair with proc datasets and this statement : repair
Here an example :
PROC DATASETS LIB = WORK;
REPAIR JUNESALES;
QUIT;
source :
http://www2.sas.com/proceedings/forum2007/070-2007.pdf
Otherwise you have to get a new file of your dataset (if you have a backup it could be useful).
Regards,

Libref is not assigned

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;

SAS: How do I Store a Macro in a Catalog

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.

SAS Apparent symbolic reference PWD not resolved

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;