<?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 Re: IF THEN DO, proc sql in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/IF-THEN-DO-proc-sql/m-p/614907#M18685</link>
    <description>&lt;P&gt;Something like below should return the same result.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  create table want as
    select 
      case
        when dx_mo="99" then "07"
        else dx_mo
      end 
      as dx_mo,
      case
        when dx_mo="99" then "01"
        when dx_dy="99" then "15"
        else dx_dy
      end 
      as dx_dy
    from have
  ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;With the sample data you've posted you'll get in the data step the following warning:&lt;/P&gt;
&lt;PRE&gt;NOTE: Character values have been converted to numeric values&lt;/PRE&gt;
&lt;P&gt;You'll observe that SQL is less tolerant here and that you need to provide the correct data types.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 03 Jan 2020 03:42:47 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2020-01-03T03:42:47Z</dc:date>
    <item>
      <title>IF THEN DO, proc sql</title>
      <link>https://communities.sas.com/t5/New-SAS-User/IF-THEN-DO-proc-sql/m-p/614904#M18684</link>
      <description>&lt;P&gt;I'm trying to learn SQL and was wondering how to recreate the second DATA step using PROC SQL.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
 input id $1. dx_mo dx_dy $2. dx_yr $4.;
 cards;
1 99 99 1994
2 02 05 1994
3 01 09 1990
4 03 03 1991
5 04 99 1993
;
run;

/* Replace missing date components with valid values */
data want;
 set have;
 if dx_mo="99" then do;
  dx_mo="07";
  dx_dy="01";
 end;
  else if dx_dy="99" then dx_dy="15";&lt;BR /&gt;run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I started with the following code but got stuck here:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
CREATE TABLE want
AS SELECT CASE
           WHEN dx_mo="99" THEN "07"
	    ELSE dx_mo
          END AS dx_mo,

          CASE
           WHEN dx_mo="99" THEN "01"
	    ELSE dx_dy
	  END AS dx_dy
FROM have;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jan 2020 03:15:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/IF-THEN-DO-proc-sql/m-p/614904#M18684</guid>
      <dc:creator>bkq32</dc:creator>
      <dc:date>2020-01-03T03:15:26Z</dc:date>
    </item>
    <item>
      <title>Re: IF THEN DO, proc sql</title>
      <link>https://communities.sas.com/t5/New-SAS-User/IF-THEN-DO-proc-sql/m-p/614907#M18685</link>
      <description>&lt;P&gt;Something like below should return the same result.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  create table want as
    select 
      case
        when dx_mo="99" then "07"
        else dx_mo
      end 
      as dx_mo,
      case
        when dx_mo="99" then "01"
        when dx_dy="99" then "15"
        else dx_dy
      end 
      as dx_dy
    from have
  ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;With the sample data you've posted you'll get in the data step the following warning:&lt;/P&gt;
&lt;PRE&gt;NOTE: Character values have been converted to numeric values&lt;/PRE&gt;
&lt;P&gt;You'll observe that SQL is less tolerant here and that you need to provide the correct data types.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jan 2020 03:42:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/IF-THEN-DO-proc-sql/m-p/614907#M18685</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-01-03T03:42:47Z</dc:date>
    </item>
    <item>
      <title>Re: IF THEN DO, proc sql</title>
      <link>https://communities.sas.com/t5/New-SAS-User/IF-THEN-DO-proc-sql/m-p/614908#M18686</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp;Thank you!&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jan 2020 03:53:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/IF-THEN-DO-proc-sql/m-p/614908#M18686</guid>
      <dc:creator>bkq32</dc:creator>
      <dc:date>2020-01-03T03:53:28Z</dc:date>
    </item>
  </channel>
</rss>

