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

I am trying to convert some SQL Server code into a SAS proc SQL format but there are a couple of things I have not figured out how to code

 

SELECT A.[KEY]

      ,A.[VOLUME]

      ,A.[DATE]

      ,A.[FLAG]

         --,[PREV_MONTH] = DATEADD(MONTH,-1,A.[DATE])

         ,[DIFFERENCE] = CASE

                                         WHEN CAST(A.[VOLUME] AS FLOAT) - CAST(B.[VOLUME] AS FLOAT) IS NULL THEN 0

                                         ELSE CAST(A.[VOLUME] AS FLOAT) - CAST(B.[VOLUME] AS FLOAT)

                                         END

         ,[SUM_] = CAST(A.[VOLUME] AS FLOAT) + CAST(B.[VOLUME] AS FLOAT)

  FROM [ATM Index].[dbo].[CIB_FINALE_2]                A

  LEFT JOIN [ATM Index].[dbo].[CIB_FINALE_2]    B

  ON          B.[KEY]  = A.[KEY]

              AND B.[FLAG] = A.[FLAG]

              AND MONTH(B.[DATE]) = MONTH(DATEADD(MONTH,-1,A.[DATE]))

  

  ORDER BY 1,3,4    

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

Hi and welcome to the SAS Communities 🙂

 

What do you have so far? And what haven't you figured out yet?

View solution in original post

2 REPLIES 2
PeterClemmensen
Tourmaline | Level 20

Hi and welcome to the SAS Communities 🙂

 

What do you have so far? And what haven't you figured out yet?

VALLY
Fluorite | Level 6

am still struggling ..i will appreciate if you could help

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 740 views
  • 0 likes
  • 2 in conversation