<?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 TO SQL in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/SAS-TO-SQL/m-p/189231#M47822</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New;"&gt;Hi ,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New;"&gt;Could some one help me with the equivalent SQL code ???&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New;"&gt;this code in basic SAS is mainly merges and a couple of transposes&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New;"&gt;thanks&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Thanks for your inputs.&lt;/P&gt;&lt;P&gt;I want to take back my question&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 09 Jun 2014 08:31:03 GMT</pubDate>
    <dc:creator>robertrao</dc:creator>
    <dc:date>2014-06-09T08:31:03Z</dc:date>
    <item>
      <title>SAS TO SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SAS-TO-SQL/m-p/189231#M47822</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New;"&gt;Hi ,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New;"&gt;Could some one help me with the equivalent SQL code ???&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New;"&gt;this code in basic SAS is mainly merges and a couple of transposes&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New;"&gt;thanks&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Thanks for your inputs.&lt;/P&gt;&lt;P&gt;I want to take back my question&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Jun 2014 08:31:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SAS-TO-SQL/m-p/189231#M47822</guid>
      <dc:creator>robertrao</dc:creator>
      <dc:date>2014-06-09T08:31:03Z</dc:date>
    </item>
    <item>
      <title>Re: SAS TO SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SAS-TO-SQL/m-p/189232#M47823</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What precisely do you want help on as I am not writing all that code.&amp;nbsp; Also, why do you need to convert it to SQL, is it to move it to a database, if so then you need to investigate the database syntax as they have additional functionality which will help.&amp;nbsp; The only thing at a quick glance that I would suggest being difficult is the transpose as SQL is built to work on normalized tables rather than transposed. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One final thing.&amp;nbsp; You may be quicker looking at your final datastep and working back from there e.g.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080; font-family: Courier New;"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New;"&gt; final(drop=&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* This becomes proc sql; create table final as&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New;"&gt; location; /* move to end */&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Courier New;"&gt;/* These are your select statements */&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Courier New;"&gt;SEX=input(put(gender_name,&lt;/SPAN&gt;&lt;SPAN style="color: #008080; font-family: Courier New;"&gt;$sex.&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New;"&gt;),&lt;/SPAN&gt;&lt;SPAN style="color: #008080; font-family: Courier New;"&gt;&lt;STRONG&gt;3.&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;SPAN style="font-family: Courier New;"&gt;RACE=input(put(Ethnic_Group,&lt;/SPAN&gt;&lt;SPAN style="color: #008080; font-family: Courier New;"&gt;$race.&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New;"&gt;),&lt;/SPAN&gt;&lt;SPAN style="color: #008080; font-family: Courier New;"&gt;&lt;STRONG&gt;3.&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;SPAN style="font-family: Courier New;"&gt;PAY1=input(put(Financial_Class,&lt;/SPAN&gt;&lt;SPAN style="color: #008080; font-family: Courier New;"&gt;$payer.&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New;"&gt;),&lt;/SPAN&gt;&lt;SPAN style="color: #008080; font-family: Courier New;"&gt;&lt;STRONG&gt;3.&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;SPAN style="font-family: Courier New;"&gt;HOSPID=input(put(Company_Code,&lt;/SPAN&gt;&lt;SPAN style="color: #008080; font-family: Courier New;"&gt;$hosp.&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New;"&gt;),&lt;/SPAN&gt;&lt;SPAN style="color: #008080; font-family: Courier New;"&gt;&lt;STRONG&gt;4.&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;SPAN style="font-family: Courier New;"&gt;DRG=MSDRG_CODE*&lt;/SPAN&gt;&lt;SPAN style="color: #008080; font-family: Courier New;"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;SPAN style="font-family: Courier New;"&gt;POINTOFORIGINUBO4=put(Admit_Source_Code,&lt;/SPAN&gt;&lt;SPAN style="color: #008080; font-family: Courier New;"&gt;$Porign.&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;SPAN style="font-family: Courier New;"&gt;MDC=input(put(DRG,&lt;/SPAN&gt;&lt;SPAN style="color: #008080; font-family: Courier New;"&gt;MDC.&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New;"&gt;),&lt;/SPAN&gt;&lt;SPAN style="color: #008080; font-family: Courier New;"&gt;best.&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;/* change to case statemtn */ &lt;SPAN style="color: #0000ff; font-family: Courier New;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New;"&gt; MSDRG_code=&lt;/SPAN&gt;&lt;SPAN style="color: #800080; font-family: Courier New;"&gt;"N/C"&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New;"&gt;then&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New;"&gt; MSDRG_code=&lt;/SPAN&gt;&lt;SPAN style="color: #800080; font-family: Courier New;"&gt;"000"&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Courier New;"&gt;/* add in here locations for each of the above variables */&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Courier New;"&gt;/* and join them */&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080; font-family: Courier New;"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New;"&gt;; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Courier New;"&gt;Note you can drop all the sort statements as SQL doesn't require pre-sorted data like SAS.&amp;nbsp; Depending on your platform, the formats will only work in SAS.&amp;nbsp; My choice is to remove that and put your formats in another dataset and use that as lookup e.g.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Courier New;"&gt;(select THIS.CODE_VALUE from CODE_DATASET THIS where THIS.CODE=BASE.CODE) as LONG_VALUE, &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Courier New;"&gt;One final thing, you use arrays at a point in your table, you would need to re-think your logic there as (I mentioned before) SQL is based on normalized (or data going down rather than across) tables.&amp;nbsp; So you may struggle to get the data going across, or have the functionality to process data across.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Courier New;"&gt;Take it bit by bit also&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Jun 2014 09:41:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SAS-TO-SQL/m-p/189232#M47823</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-06-09T09:41:30Z</dc:date>
    </item>
    <item>
      <title>Re: SAS TO SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SAS-TO-SQL/m-p/189233#M47824</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I believe you need to ask a bit more educated and targeted questions. You can't really expect anyone to just do all the work for you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You would also need to explain why this needs to be done using SQL.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Jun 2014 09:48:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SAS-TO-SQL/m-p/189233#M47824</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2014-06-09T09:48:14Z</dc:date>
    </item>
  </channel>
</rss>

