I am trying to insert a data in SQL server table using SAS
Below is the code that I have written
%macro lzlib;
LIBNAME LZZ OLEDB BULKLOAD=YES
DBCOMMIT=0
CURSOR_TYPE=STATIC
BL_KEEPIDENTITY=YES
BL_KEEPNULLS=NO
DIRECT_EXE=DELETE
PROPERTIES=('Integrated Security'=SSPI
'Persist Security Info'=TRUE
'Initial Catalog'=Customer_account)
PROMPT=NO
REREAD_EXPOSURE=NO
PROVIDER=SQLOLEDB
DATASOURCE="dwh-i-sql"
SCHEMA=DZS
ROWSET_SIZE=32767
UPDATE_MULT_ROWS=YES
PRESERVE_GUID=yes;
PROC SQL;
INSERT INTO LZZ.CUST_DIM
SELECT DATO
,JOBNAME
,RUNDATE
,EXECUTION_STATUS
,COMPARE
,LcOMPARE_RESULT
,OUTPUT_FLAT_FILE_EXISTS
,FOLDER_LINK
,FILE_NAME
,ADD_INFO
,FILE_EXISTS
,HOST_FILE_DOWNLOAD
,FILE_READ
,HOST_FILE_READ
,COMPARE_PROCEDURE
,COMPARE_STATUS
,BASEDATASETOBS
,COMPAREDATASETOBS
,BASEDATASETVAR
,COMPAREDATASETVAR FROM FINAL;
QUIT;
%mend;
This is the error that comes up
ERROR: Execute error: IRowsetFastLoad::InsertRow failed. : Unspecified error
ERROR: ROLLBACK issued due to errors for data set LZZ.CUST_DIM.DATA.
Thanks!!
Try
options msglevel=i sastrace=',,,d' sastraceloc=saslog;
Might give you some more info in the log.
Check the data and try to see if they break any constraints, or if you have any read only columns.
Check in SQL Server logs, enable additional audit if necessary.
I found this ancient discussion: https://communities.sas.com/t5/General-SAS-Programming/Using-DI-Studio-to-build-a-data-warehouse-in-...
Most likely you have a type conflict for one of the column or perhaps just one of the values for one of the columns.
Find an example observation that it cannot insert.
Then repeatally try loading the row with different combinations of variables selected to see which variable(s) are causing the problem.
You should probably check the date varaibles first. SAS stores DATE and DATETIME values differently, but many DBMS have only one data type for dates. You might need to convert your SAS DATE value to a DATETIME value to put it into the target variable.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.