BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
prad001
Obsidian | Level 7

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

1 ACCEPTED SOLUTION
3 REPLIES 3
Tom
Super User Tom
Super User

You need to tell SAS that you want to run the command on the remote.

execute by ODBC 
(
ABOVE SQL CODE
);
prad001
Obsidian | Level 7

Thank you Kurt and Tom.

"Execute" is what I missed. It works fine now.

 

Thank you both again.

sas-innovate-white.png

🚨 Early Bird Rate Extended!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.

 

Lock in the best rate now before the price increases on April 1.

Register now!

How to connect to databases in SAS Viya

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.

Discussion stats
  • 3 replies
  • 2775 views
  • 3 likes
  • 3 in conversation