Hi everyone, I wonder if there is a way I can run SQL code directly in SAS. I know I can run something like this below: PROC SQL; CONNECT TO ODBC as con (DATASRC="ABCREPORTING: Prod_Report" authdomain=SQLGRP_Temp_Reader_Auth); CREATE TABLE ABC_Table AS SELECT * FROM CONNECTION TO con2 ( SELECT CASE BiasVa WHEN 1 THEN 'OO WHEN 2 THEN 'PP' END AS ABC_Type, UnitId, Stbi AS ABC_EWMA, AverageLightValue AS Avg_Actual, CONVERT(datetime, StartDateTime) AS StartDateTime, CONVERT(datetime, EndDateTime) AS EndDateTime FROM Derating.UnitStbiParameter WHERE UnitID IN (1,2,3,4,5,6) AND BiasCodeId IN (1,2) AND ((EndDateTime > StartDateTime) OR EndDateTime IS NULL ) GROUP BY UnitId, ABC, AverageLightValue, StartDateTime, EndDateTime Order By StartDateTime Desc, Unitid Asc ); However, I feel like you cannot run something with special key words in SAS like below(the declare or @sign etc may not be executed properly) DECLARE @InvestigationId VARCHAR(5) = '1166 IF object_id('tempdb..#ScanHistory') IS NOT NULL DROP TABLE #ScanHistory SELECT ROW_NUMBER() OVER(ORDER BY IM.SubID, MSH.CreatedTime) AS RowID ,IM.InvestigationID ,IM.SubID ,IM.SampleDescription ,MS.Name [ModuleSubgroupName] ,CASE TE.TestFacilityID WHEN 2 THEN 'OTS' WHEN 10 THEN 'ATS' WHEN 11 THEN 'FTS' ELSE NULL END [ParentSiteID] ,RIGHT(TE.EquipmentCode,4) [ArrayID] ,CASE WHEN ID.InverterModel != 'AUT 5.8' THEN 1 ELSE CASE WHEN CAST(TES.SName AS INT) > 10 THEN 2 ELSE 1 END END [MPPT] ,ID.InverterModel ,TE.EquipmentCode ,TE.MaxSlots ,TES.SName ,MSH.ReasonCode INTO #ScanHistory FROM ReliabilityDB_Report.dbo.RT_InvestigationModules IM WITH (NOLOCK) inner join ................................................................. Just wonder if there is a way you can run SQL code directly without modifying it; Also typically when you have SQL code in hand but need to run the same thing in SAS, what is the best practice to do? Thank you, Tao
... View more