<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic SAS Conversion to SQL in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-Conversion-to-SQL/m-p/831792#M328752</link>
    <description>&lt;P&gt;I need to convert SAS to SQL; Right now, I am trying to convert the below SAS code to SQL and for me it’s the first time to convert the SAS script.&lt;/P&gt;&lt;P&gt;Please could anybody explain what the following does, or if possible, the equivalent in SQL?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;BR /&gt;CONNECT TO DB2(SSID=DB0P);&lt;BR /&gt;CREATE TABLE dclhcl AS SELECT *&lt;BR /&gt;FROM CONNECTION TO DB2&lt;BR /&gt;(SELECT&lt;BR /&gt;HCd_SITE_ID,&lt;BR /&gt;HCd_AUDNBR,&lt;BR /&gt;0,&lt;BR /&gt;HCd_PROV1,&lt;BR /&gt;HCd_memgrp,&lt;BR /&gt;HCd_from_YMD,&lt;BR /&gt;HCd_DTPD_YMD,&lt;BR /&gt;HCd_AMT_PAID,&lt;BR /&gt;HCd_DSLW_CDE_OTH,&lt;BR /&gt;HCd_REVENUE_CDE,&lt;BR /&gt;HCd_AMT_CLAIMED,&lt;BR /&gt;HCd_AMT_DSLW_OTH,&lt;BR /&gt;HCD_AMT_COPAY,&lt;BR /&gt;HCD_AMT_DEDUCT,&lt;BR /&gt;HCD_AMT_CONTRACT,&lt;BR /&gt;hCd_RECID,&lt;BR /&gt;'HOS',&lt;BR /&gt;HCd_ENTRY_YMD,&lt;BR /&gt;HCd_ADJ_SEQ_NBR,&lt;BR /&gt;HCD_DTL_DENY_FLG,&lt;BR /&gt;HCD_PRV_PAR_CDE,&lt;BR /&gt;hCM_CLOSE_FLG,&lt;BR /&gt;hCm_FED_TAX_ID,&lt;BR /&gt;HCm_RCV_YMD,&lt;BR /&gt;hcm_diagnosis_cd1,&lt;BR /&gt;HCm_DENIAL_CDE,&lt;BR /&gt;HCm_RVW_RSN_CDE1,&lt;BR /&gt;HCm_RVW_RSN_CDE2,&lt;BR /&gt;HCm_RVW_RSN_CDE3,&lt;BR /&gt;HCm_RVW_RSN_CDE4,&lt;BR /&gt;HCm_RVW_RSN_CDE5,&lt;BR /&gt;HCm_RVW_RSN_CDE6,&lt;BR /&gt;HCm_RVW_RSN_CDE7,&lt;BR /&gt;HCm_RVW_RSN_CDE8,&lt;BR /&gt;HCm_RVW_RSN_CDE9,&lt;BR /&gt;HCm_RVW_RSN_CDE0,&lt;BR /&gt;hcm_PROCESS_CDE,&lt;BR /&gt;HCM_TYPE_OF_BILL,&lt;BR /&gt;HCM_REOPEN_FLG,&lt;BR /&gt;HCM_CLAIM_TYPE,&lt;BR /&gt;hcm_sec_source,&lt;BR /&gt;HCM_TOT_CLAIMED,&lt;BR /&gt;HCM_TOT_DSLW_OTH&lt;/P&gt;&lt;P&gt;FROM QDSPR.uhcHLdetl,&lt;BR /&gt;QDSPR.uhchlmast&lt;BR /&gt;WHERE&lt;BR /&gt;hcm_site_id=hcd_site_id&lt;BR /&gt;and hcm_audnbr=hcd_audnbr&lt;BR /&gt;and hcm_recid=hcd_recid&lt;BR /&gt;and HCM_ADJ_SEQ_NBR=HCD_ADJ_SEQ_NBR&lt;/P&gt;&lt;P&gt;and (hcm_dtpd_ymd between '2020-02-16' and '2020-02-22')&lt;BR /&gt;AND hcm_PROCESS_CDE in(3,4,5,6,7)&lt;BR /&gt;AND (HCM_fed_tax_id &amp;amp;tins)&lt;BR /&gt;and hcm_site_id &amp;amp;divs&lt;BR /&gt;and hcm_FIN_PRD_NBR not &amp;amp;fp&lt;BR /&gt;with ur&lt;BR /&gt;)&lt;BR /&gt;AS EXTRACT(&lt;BR /&gt;HMOID,&lt;BR /&gt;AUDNBR,&lt;BR /&gt;AUDsub,&lt;BR /&gt;PROVIDER,&lt;BR /&gt;memgrp,&lt;BR /&gt;FROM_YMD,&lt;BR /&gt;PAID_YMD,&lt;BR /&gt;AMT_PAID,&lt;BR /&gt;rsn_CDE,&lt;BR /&gt;revenue,&lt;BR /&gt;AMT_CLAI,&lt;BR /&gt;AMT_DISA,&lt;BR /&gt;AMT_COPA,&lt;BR /&gt;AMT_DEDU,&lt;BR /&gt;AMT_CONT,&lt;BR /&gt;recid,&lt;BR /&gt;type,&lt;BR /&gt;entr_ymd,&lt;BR /&gt;sys_seq,&lt;BR /&gt;den_flg,&lt;BR /&gt;par_cde,&lt;BR /&gt;clos_flg,&lt;BR /&gt;FEDTAXID,&lt;BR /&gt;recv_YMD,&lt;BR /&gt;diag_CDE,&lt;BR /&gt;DEN_CDE,&lt;BR /&gt;rvw1,&lt;BR /&gt;rvw2,&lt;BR /&gt;rvw3,&lt;BR /&gt;rvw4,&lt;BR /&gt;rvw5,&lt;BR /&gt;rvw6,&lt;BR /&gt;rvw7,&lt;BR /&gt;rvw8,&lt;BR /&gt;rvw9,&lt;BR /&gt;rvw10,&lt;BR /&gt;process,&lt;BR /&gt;bill_typ,&lt;BR /&gt;reopen,&lt;BR /&gt;cov_typ,&lt;BR /&gt;src,&lt;BR /&gt;TOT_CLAI,&lt;BR /&gt;TOT_DISA&lt;BR /&gt;);&lt;BR /&gt;%put &amp;amp;sqlxmsg;&lt;BR /&gt;&lt;BR /&gt;* check for partial denials;&lt;BR /&gt;data dens; set dclhcl;&lt;BR /&gt;if tot_clai ¬= tot_disa and amt_clai = amt_disa and amt_clai ¬= 0&lt;BR /&gt;and rsn_cde &amp;gt; 0 and rsnflg="D" then do;&lt;BR /&gt;outcome="PARTIAL DENY";&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;BR /&gt;data dens;&lt;BR /&gt;keep hmoid audnbr audsub recid sys_seq outcome;&lt;BR /&gt;set dens;&lt;BR /&gt;run;&lt;BR /&gt;proc sort data=dens nodupkey;&lt;BR /&gt;by hmoid audnbr audsub recid sys_seq outcome;&lt;BR /&gt;run;&lt;BR /&gt;proc sort data=dclhcl;&lt;BR /&gt;by hmoid audnbr audsub recid sys_seq;&lt;BR /&gt;run;&lt;BR /&gt;data dclhcl;&lt;BR /&gt;merge dens (in=ind) dclhcl (in=inh);&lt;BR /&gt;by hmoid audnbr audsub recid sys_seq;&lt;BR /&gt;if inh;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;My conversion of the summary block:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;CREATE TABLE dclhcl&lt;BR /&gt;(&lt;BR /&gt;HMOID,AUDNBR,AUDsub,PROVIDER,memgrp,FROM_YMD,PAID_YMD,AMT_PAID,&lt;BR /&gt;................&lt;BR /&gt;TOT_CLAI,&lt;BR /&gt;TOT_DISA&lt;BR /&gt;)&lt;BR /&gt;&lt;BR /&gt;data dens; set dclhcl;&lt;BR /&gt;if tot_clai ¬= tot_disa and amt_clai = amt_disa and amt_clai ¬= 0&lt;BR /&gt;and rsn_cde &amp;gt; 0 and rsnflg="D" then do;&lt;BR /&gt;outcome="PARTIAL DENY";&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;From the above step&amp;nbsp;if tot_clai ¬= tot_disa and amt_clai = amt_disa and amt_clai ¬= 0 onwards I am unable to convert&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 05 Sep 2022 10:47:53 GMT</pubDate>
    <dc:creator>venu5876</dc:creator>
    <dc:date>2022-09-05T10:47:53Z</dc:date>
    <item>
      <title>SAS Conversion to SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Conversion-to-SQL/m-p/831792#M328752</link>
      <description>&lt;P&gt;I need to convert SAS to SQL; Right now, I am trying to convert the below SAS code to SQL and for me it’s the first time to convert the SAS script.&lt;/P&gt;&lt;P&gt;Please could anybody explain what the following does, or if possible, the equivalent in SQL?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;BR /&gt;CONNECT TO DB2(SSID=DB0P);&lt;BR /&gt;CREATE TABLE dclhcl AS SELECT *&lt;BR /&gt;FROM CONNECTION TO DB2&lt;BR /&gt;(SELECT&lt;BR /&gt;HCd_SITE_ID,&lt;BR /&gt;HCd_AUDNBR,&lt;BR /&gt;0,&lt;BR /&gt;HCd_PROV1,&lt;BR /&gt;HCd_memgrp,&lt;BR /&gt;HCd_from_YMD,&lt;BR /&gt;HCd_DTPD_YMD,&lt;BR /&gt;HCd_AMT_PAID,&lt;BR /&gt;HCd_DSLW_CDE_OTH,&lt;BR /&gt;HCd_REVENUE_CDE,&lt;BR /&gt;HCd_AMT_CLAIMED,&lt;BR /&gt;HCd_AMT_DSLW_OTH,&lt;BR /&gt;HCD_AMT_COPAY,&lt;BR /&gt;HCD_AMT_DEDUCT,&lt;BR /&gt;HCD_AMT_CONTRACT,&lt;BR /&gt;hCd_RECID,&lt;BR /&gt;'HOS',&lt;BR /&gt;HCd_ENTRY_YMD,&lt;BR /&gt;HCd_ADJ_SEQ_NBR,&lt;BR /&gt;HCD_DTL_DENY_FLG,&lt;BR /&gt;HCD_PRV_PAR_CDE,&lt;BR /&gt;hCM_CLOSE_FLG,&lt;BR /&gt;hCm_FED_TAX_ID,&lt;BR /&gt;HCm_RCV_YMD,&lt;BR /&gt;hcm_diagnosis_cd1,&lt;BR /&gt;HCm_DENIAL_CDE,&lt;BR /&gt;HCm_RVW_RSN_CDE1,&lt;BR /&gt;HCm_RVW_RSN_CDE2,&lt;BR /&gt;HCm_RVW_RSN_CDE3,&lt;BR /&gt;HCm_RVW_RSN_CDE4,&lt;BR /&gt;HCm_RVW_RSN_CDE5,&lt;BR /&gt;HCm_RVW_RSN_CDE6,&lt;BR /&gt;HCm_RVW_RSN_CDE7,&lt;BR /&gt;HCm_RVW_RSN_CDE8,&lt;BR /&gt;HCm_RVW_RSN_CDE9,&lt;BR /&gt;HCm_RVW_RSN_CDE0,&lt;BR /&gt;hcm_PROCESS_CDE,&lt;BR /&gt;HCM_TYPE_OF_BILL,&lt;BR /&gt;HCM_REOPEN_FLG,&lt;BR /&gt;HCM_CLAIM_TYPE,&lt;BR /&gt;hcm_sec_source,&lt;BR /&gt;HCM_TOT_CLAIMED,&lt;BR /&gt;HCM_TOT_DSLW_OTH&lt;/P&gt;&lt;P&gt;FROM QDSPR.uhcHLdetl,&lt;BR /&gt;QDSPR.uhchlmast&lt;BR /&gt;WHERE&lt;BR /&gt;hcm_site_id=hcd_site_id&lt;BR /&gt;and hcm_audnbr=hcd_audnbr&lt;BR /&gt;and hcm_recid=hcd_recid&lt;BR /&gt;and HCM_ADJ_SEQ_NBR=HCD_ADJ_SEQ_NBR&lt;/P&gt;&lt;P&gt;and (hcm_dtpd_ymd between '2020-02-16' and '2020-02-22')&lt;BR /&gt;AND hcm_PROCESS_CDE in(3,4,5,6,7)&lt;BR /&gt;AND (HCM_fed_tax_id &amp;amp;tins)&lt;BR /&gt;and hcm_site_id &amp;amp;divs&lt;BR /&gt;and hcm_FIN_PRD_NBR not &amp;amp;fp&lt;BR /&gt;with ur&lt;BR /&gt;)&lt;BR /&gt;AS EXTRACT(&lt;BR /&gt;HMOID,&lt;BR /&gt;AUDNBR,&lt;BR /&gt;AUDsub,&lt;BR /&gt;PROVIDER,&lt;BR /&gt;memgrp,&lt;BR /&gt;FROM_YMD,&lt;BR /&gt;PAID_YMD,&lt;BR /&gt;AMT_PAID,&lt;BR /&gt;rsn_CDE,&lt;BR /&gt;revenue,&lt;BR /&gt;AMT_CLAI,&lt;BR /&gt;AMT_DISA,&lt;BR /&gt;AMT_COPA,&lt;BR /&gt;AMT_DEDU,&lt;BR /&gt;AMT_CONT,&lt;BR /&gt;recid,&lt;BR /&gt;type,&lt;BR /&gt;entr_ymd,&lt;BR /&gt;sys_seq,&lt;BR /&gt;den_flg,&lt;BR /&gt;par_cde,&lt;BR /&gt;clos_flg,&lt;BR /&gt;FEDTAXID,&lt;BR /&gt;recv_YMD,&lt;BR /&gt;diag_CDE,&lt;BR /&gt;DEN_CDE,&lt;BR /&gt;rvw1,&lt;BR /&gt;rvw2,&lt;BR /&gt;rvw3,&lt;BR /&gt;rvw4,&lt;BR /&gt;rvw5,&lt;BR /&gt;rvw6,&lt;BR /&gt;rvw7,&lt;BR /&gt;rvw8,&lt;BR /&gt;rvw9,&lt;BR /&gt;rvw10,&lt;BR /&gt;process,&lt;BR /&gt;bill_typ,&lt;BR /&gt;reopen,&lt;BR /&gt;cov_typ,&lt;BR /&gt;src,&lt;BR /&gt;TOT_CLAI,&lt;BR /&gt;TOT_DISA&lt;BR /&gt;);&lt;BR /&gt;%put &amp;amp;sqlxmsg;&lt;BR /&gt;&lt;BR /&gt;* check for partial denials;&lt;BR /&gt;data dens; set dclhcl;&lt;BR /&gt;if tot_clai ¬= tot_disa and amt_clai = amt_disa and amt_clai ¬= 0&lt;BR /&gt;and rsn_cde &amp;gt; 0 and rsnflg="D" then do;&lt;BR /&gt;outcome="PARTIAL DENY";&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;BR /&gt;data dens;&lt;BR /&gt;keep hmoid audnbr audsub recid sys_seq outcome;&lt;BR /&gt;set dens;&lt;BR /&gt;run;&lt;BR /&gt;proc sort data=dens nodupkey;&lt;BR /&gt;by hmoid audnbr audsub recid sys_seq outcome;&lt;BR /&gt;run;&lt;BR /&gt;proc sort data=dclhcl;&lt;BR /&gt;by hmoid audnbr audsub recid sys_seq;&lt;BR /&gt;run;&lt;BR /&gt;data dclhcl;&lt;BR /&gt;merge dens (in=ind) dclhcl (in=inh);&lt;BR /&gt;by hmoid audnbr audsub recid sys_seq;&lt;BR /&gt;if inh;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;My conversion of the summary block:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;CREATE TABLE dclhcl&lt;BR /&gt;(&lt;BR /&gt;HMOID,AUDNBR,AUDsub,PROVIDER,memgrp,FROM_YMD,PAID_YMD,AMT_PAID,&lt;BR /&gt;................&lt;BR /&gt;TOT_CLAI,&lt;BR /&gt;TOT_DISA&lt;BR /&gt;)&lt;BR /&gt;&lt;BR /&gt;data dens; set dclhcl;&lt;BR /&gt;if tot_clai ¬= tot_disa and amt_clai = amt_disa and amt_clai ¬= 0&lt;BR /&gt;and rsn_cde &amp;gt; 0 and rsnflg="D" then do;&lt;BR /&gt;outcome="PARTIAL DENY";&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;From the above step&amp;nbsp;if tot_clai ¬= tot_disa and amt_clai = amt_disa and amt_clai ¬= 0 onwards I am unable to convert&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Sep 2022 10:47:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Conversion-to-SQL/m-p/831792#M328752</guid>
      <dc:creator>venu5876</dc:creator>
      <dc:date>2022-09-05T10:47:53Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Conversion to SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Conversion-to-SQL/m-p/831793#M328753</link>
      <description>&lt;P&gt;Taking a step back ... why convert to SQL if you have working SAS code? Seems like an unnecessary thing to do.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Sep 2022 10:56:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Conversion-to-SQL/m-p/831793#M328753</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-09-05T10:56:40Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Conversion to SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Conversion-to-SQL/m-p/831795#M328755</link>
      <description>&lt;P&gt;We are using SQL Server as a backend database for one product. For that product this SAS script data is required. So I am developing the Stored Procedure with the above SAS Conditions in SQL...&lt;BR /&gt;That is the reason I am trying to convert the below condition in SQL. Could you please suggest me on this!!&lt;/P&gt;&lt;P&gt;if tot_clai ¬= tot_disa and amt_clai = amt_disa and amt_clai ¬= 0&lt;BR /&gt;and rsn_cde &amp;gt; 0 and rsnflg="D" then do;&lt;BR /&gt;outcome="PARTIAL DENY";&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Sep 2022 11:07:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Conversion-to-SQL/m-p/831795#M328755</guid>
      <dc:creator>venu5876</dc:creator>
      <dc:date>2022-09-05T11:07:41Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Conversion to SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Conversion-to-SQL/m-p/831796#M328756</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/433032"&gt;@venu5876&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Could you please suggest me on this!!&lt;/P&gt;
&lt;P&gt;if tot_clai ¬= tot_disa and amt_clai = amt_disa and amt_clai ¬= 0&lt;BR /&gt;and rsn_cde &amp;gt; 0 and rsnflg="D" then do;&lt;BR /&gt;outcome="PARTIAL DENY";&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The equivalent of a SAS IF statement in SQL is the CASE WHEN statement.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Sep 2022 11:20:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Conversion-to-SQL/m-p/831796#M328756</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-09-05T11:20:24Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Conversion to SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Conversion-to-SQL/m-p/831801#M328760</link>
      <description>&lt;P&gt;Just to set the expectations - this is a site for persons that wants to learn (and teach) SAS, not for decommission SAS solutions.&lt;/P&gt;
&lt;P&gt;A bit harsh, but if your project need SAS knowledge, pay for it.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Sep 2022 12:36:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Conversion-to-SQL/m-p/831801#M328760</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2022-09-05T12:36:32Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Conversion to SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Conversion-to-SQL/m-p/831802#M328761</link>
      <description>&lt;P&gt;Thanks for your support&amp;nbsp;&lt;BR /&gt;I have used the CASE Statement as suggested. It worked&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Sep 2022 12:49:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Conversion-to-SQL/m-p/831802#M328761</guid>
      <dc:creator>venu5876</dc:creator>
      <dc:date>2022-09-05T12:49:29Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Conversion to SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Conversion-to-SQL/m-p/831803#M328762</link>
      <description>&lt;P&gt;As you suggested I will use this portal as a SAS learning Hub&amp;nbsp;&lt;BR /&gt;Thanks for your time and support.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Sep 2022 12:50:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Conversion-to-SQL/m-p/831803#M328762</guid>
      <dc:creator>venu5876</dc:creator>
      <dc:date>2022-09-05T12:50:54Z</dc:date>
    </item>
  </channel>
</rss>

