Hi All,
I am trying to insert rows in SQL Server DB using SAS SQL Pass through facility.
The below code works fine in SQL but I am not sure what I am missing while I am incorporating it in SAS. Could you please tell me the appropriate changes to be made in SAS.
USE [SDMS] GO INSERT INTO [sur].[FactSurveyTotal] ([SurveySK] ,[TotalTypeNm] ,[TotalSubTypeNm] ,[DOSTotalCnt] ,[EDWTotalCnt] ,[WithNAPct] ,[WithoutNAPct] ) VALUES ( (SELECT SurveySK FROM sur.DimSurvey where SurveyYearNum='2020' AND SurveyTypeNm='Physician') ,'Test Type' , 'Test SubType' ,1 ,2 ,3 ,4 )
With
proc sql; connect to odbc(dsn="XXXXXX" user=XXXX password="XXXXX" ); ( ABOVE SQL CODE ); QUIT;
Am I missing anything or should I modify the sql code in any way ?
Thank you,
Prad
For a pure pass-through command, you need the SAS SQL EXECUTE statement.
For a pure pass-through command, you need the SAS SQL EXECUTE statement.
You need to tell SAS that you want to run the command on the remote.
execute by ODBC
(
ABOVE SQL CODE
);
Thank you Kurt and Tom.
"Execute" is what I missed. It works fine now.
Thank you both again.
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!
Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.