<?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: How to create variables in PROC SQL? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-variables-in-PROC-SQL/m-p/340643#M77883</link>
    <description>&lt;PRE&gt;proc sql;
  create table newtable as
    select case(myvar)
      when ('N') then 'No'
      when ('Y') then 'Yes'
     end as newvar length=5
       from table
  ;
  quit;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 14 Mar 2017 04:31:07 GMT</pubDate>
    <dc:creator>art297</dc:creator>
    <dc:date>2017-03-14T04:31:07Z</dc:date>
    <item>
      <title>How to create variables in PROC SQL?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-variables-in-PROC-SQL/m-p/340637#M77878</link>
      <description>&lt;P&gt;in data step&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following will create a new variable newvar based on myvar and drop myvar&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data newtable(drop = myvar);
&amp;nbsp; &amp;nbsp;length newvar %5;
&amp;nbsp; &amp;nbsp;set table;
&amp;nbsp; &amp;nbsp;if myvar = N then newvar = No
&amp;nbsp; &amp;nbsp;if myvar = Y then newvar = Yes
run;&lt;/PRE&gt;&lt;P&gt;How can I replicate this in SAS&amp;nbsp;proc sql?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Mar 2017 04:04:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-variables-in-PROC-SQL/m-p/340637#M77878</guid>
      <dc:creator>afiqcjohari</dc:creator>
      <dc:date>2017-03-14T04:04:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to create variables in PROC SQL?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-variables-in-PROC-SQL/m-p/340642#M77882</link>
      <description>&lt;P&gt;That's not valid SAS code to start with...&lt;/P&gt;
&lt;P&gt;As always, see the documentation or search at lexjansen.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://support.sas.com/documentation/cdl/en/sqlproc/69822/HTML/default/viewer.htm#n1spf244gkq54cn13bbiy307hknr.htm" target="_blank"&gt;https://support.sas.com/documentation/cdl/en/sqlproc/69822/HTML/default/viewer.htm#n1spf244gkq54cn13bbiy307hknr.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.lexjansen.com/search/searchresults.php?q=Intro%20to%20proc%20sql" target="_blank"&gt;http://www.lexjansen.com/search/searchresults.php?q=Intro%20to%20proc%20sql&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www2.sas.com/proceedings/sugi29/268-29.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi29/268-29.pdf&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Mar 2017 04:28:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-variables-in-PROC-SQL/m-p/340642#M77882</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-03-14T04:28:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to create variables in PROC SQL?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-variables-in-PROC-SQL/m-p/340643#M77883</link>
      <description>&lt;PRE&gt;proc sql;
  create table newtable as
    select case(myvar)
      when ('N') then 'No'
      when ('Y') then 'Yes'
     end as newvar length=5
       from table
  ;
  quit;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Mar 2017 04:31:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-variables-in-PROC-SQL/m-p/340643#M77883</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-03-14T04:31:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to create variables in PROC SQL?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-variables-in-PROC-SQL/m-p/340644#M77884</link>
      <description>&lt;PRE&gt;proc sql;
create table test as
select case
when myvar= 'N' then 'LCY'
when myvar = 'Y' then 'FCY'
end as newvar
from table
;quit;&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Mar 2017 04:32:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-variables-in-PROC-SQL/m-p/340644#M77884</guid>
      <dc:creator>afiqcjohari</dc:creator>
      <dc:date>2017-03-14T04:32:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to create variables in PROC SQL?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-variables-in-PROC-SQL/m-p/340645#M77885</link>
      <description>Ok, I missed the length option. Thanks!</description>
      <pubDate>Tue, 14 Mar 2017 04:33:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-variables-in-PROC-SQL/m-p/340645#M77885</guid>
      <dc:creator>afiqcjohari</dc:creator>
      <dc:date>2017-03-14T04:33:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to create variables in PROC SQL?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-variables-in-PROC-SQL/m-p/340646#M77886</link>
      <description>That lexjansen is going to be very useful. Thanks Reeza!</description>
      <pubDate>Tue, 14 Mar 2017 04:34:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-variables-in-PROC-SQL/m-p/340646#M77886</guid>
      <dc:creator>afiqcjohari</dc:creator>
      <dc:date>2017-03-14T04:34:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to create variables in PROC SQL?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-variables-in-PROC-SQL/m-p/340708#M77926</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just to add, when doing binary choices such as this its useful to use ifn/ifc functions to shrink the code (note this would not work for pass-through):&lt;/P&gt;
&lt;PRE&gt;data newtable;
  set table;
  newvar=ifc(myvar="N","No","Yes");
run;

proc sql;
  create table NEWTABLE as
  select  ifc(MYVAR="N","No","Yes") as NEWVAR
  from    TABLE;
quit;&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Mar 2017 09:31:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-variables-in-PROC-SQL/m-p/340708#M77926</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-03-14T09:31:31Z</dc:date>
    </item>
  </channel>
</rss>

