SAS data step error "too long for buffer" - sas

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,

Related

SAS PassThru to Snowflake using EXECUTE( %include <program?) by SNOW; Error

This process works with pass thru to Teradata. We are migrating to Snowflake. I create a program using a data step and put statements INSERT INTO TEMPTABLE VALUES('VAR', 'VAR', 'VAR, VAR', 'VAR, 'VAR', 'VAR'); The execute () by snow; works when I copy each record into the direct sas code. However, we don't know how many rows we will have on a given day and this process is automated, so the this was a way to be hand free.
The TD code that works great:
EXECUTE(
BT;
%include "/&srv./&fldr./programs/ORG_JOB_DPT_LKP.sas";
ET;
) BY TERA;
Previous errors are similar for the BT and ET:
ERROR: CLI execute error: SQL compilation error: syntax error line 1 at position 0 unexpected '%'.
I have also tried to send the multiple insert rows over as a macro variable with a %let = %();
I receive the same unexpected "&" when trying to call the variable.
I haven't been able to find any documentation that suggests this shouldn't work.

Finding PID responsible for "ERROR: A lock is not available for"

On UNIX systems, if a file lock is held, the error message includes a PID, eg:
ERROR: A lock is not available for XXX.XXXX.
ERROR: Lock held by process 4653302.
For windows, the guilty process is not provided. Is there a way I can find out who locked the table? I cannot log onto the machine, however the server does have XCMD enabled.
FWIW, the FILELOCKWAIT option is not helpful here (it's a long running lock).
EDIT: I am not an administrator, and I cannot download third party tools
wmic provides almost anything you want about the goings on in Windows.
win32_process will tell you (if your account has the proper policy settings) all about who is running what. Find the SASers and call em up ?
Example: Proc IMPORT can't read a pipe, so save the wmic output to a file first.
%let wmic_cmd = wmic path win32_process where "description like '%nrstr(%%sas.exe%%)'";
filename whosas pipe
"%superq(wmic_cmd) get /format:csv | findstr /r /v ""^$"" > c:\temp\wmic_whosas.txt"
;
data _null_;
infile whosas;
input;
run;
proc import dbms=csv datafile="c:\temp\wmic_whosas.txt" replace out=whosas;
run;
Should get you 47 pieces of info about each SAS process.
If you don't have permissions, IT will have to grant them, or get involved with you so often they eventually do :)

Unzipping files in SAS

I was wondering if you could help me understand a piece of SAS code that I found to unzip files from SAS in UNIX? I found this code to zip the file, but I am unsure how to unzip the file.
/*x gunzip /sasdata3/MI/projects/hedis_vendor/production/inovprev/data/download/M201803/Process/unprocessed/invbsca_aba18_detail_fcr_r12_with_ce_20180330_summary_detail_dongmei_march_rolling12_preview_3_31_2018_4_18_26_pm.zip.gz;
DATA _NULL_;
tstring='gzip /sasdata3/MI/projects/hedis_vendor/production/inovprev/data/download/M201803/Process/unprocessed/invbsca_aba18_detail_fcr_r12_with_ce_20180330_summary_detail_dongmei_march_rolling12_preview_3_31_2018_4_18_26_pm.zip;';
rc = SYSTEM(tstring);
RUN; */;
I hope you find my explanation below useful:
The code you sent is commented out. In SAS any thing between /* some code/comments */ will be treated as comments.
It looks like your environment have X command enabled in SAS; this means you can run Operating System commands via SAS code.
DATA _NULL_; /* Empty data step which will not create any table*/
tstring=' some OS command like gzip or gunzip'; /*The OS cmd is places here*/
rc = SYSTEM(tstring); /*SAS invokes the OS and executes the command saved in the variable tstring*/
RUN;
This code have to commands which you can place either of them in the tstring='';
Zip:
gzip /sasdata3/MI/projects/hedis_vendor/production/inovprev/data/download/M201803/Process/unprocessed/invbsca_aba18_detail_fcr_r12_with_ce_20180330_summary_detail_dongmei_march_rolling12_preview_3_31_2018_4_18_26_pm.zip;
Unzip:
gunzip /sasdata3/MI/projects/hedis_vendor/production/inovprev/data/download/M201803/Process/unprocessed/invbsca_aba18_detail_fcr_r12_with_ce_20180330_summary_detail_dongmei_march_rolling12_preview_3_31_2018_4_18_26_pm.zip.gz;
gzip & guzip examples

SAS proc import xlsm files

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.

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;