<?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: PROC SQL : Create many variables from one variable using case in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-Create-many-variables-from-one-variable-using-case/m-p/77515#M16788</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your code is doing the opposite of your request. You care creating one variable from many variables.&lt;/P&gt;&lt;P&gt;To make many variables you would need many CASE statements.&amp;nbsp; Assuming you want to split copy TPJNL into variables D2,D3,... then use something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;select&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; case when (&lt;SPAN style="font-family: 'courier new', courier;"&gt;NM='Medical') then TPJNL else . end as D2&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; ,case when (NM='Income') then TPJNL else . end as D3&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 10 Apr 2012 17:16:57 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2012-04-10T17:16:57Z</dc:date>
    <item>
      <title>PROC SQL : Create many variables from one variable using case</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-Create-many-variables-from-one-variable-using-case/m-p/77514#M16787</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please find the code below : I want to create variables D2, D3, D4, D5,D6,D7 and D8 from variable TPjNL based on conditions... But somehow I am not able to produce it correctly... Need help on this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080;"&gt;&lt;STRONG&gt;PROC&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;STRONG&gt;SQL&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;NOPRINT&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;CREATE&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;TABLE&lt;SPAN style="color: #000000;"&gt; TEMP &lt;/SPAN&gt;AS&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="color: #0000ff;"&gt;SELECT&lt;/SPAN&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;CASE&amp;nbsp; TPjNL &lt;SPAN style="color: #0000ff;"&gt;WHEN&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt; NM=&lt;SPAN style="color: #800080;"&gt;"Medical "&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;THEN&lt;/SPAN&gt;&amp;nbsp; D2 ,&lt;/P&gt;&lt;P&gt;ELSE &lt;SPAN style="color: #0000ff;"&gt;WHEN&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; NM=&lt;SPAN style="color: #800080;"&gt;"Income "&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;THEN&lt;/SPAN&gt; D3 ,&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;SPAN style="color: #575757;"&gt;ELSE &lt;/SPAN&gt;WHEN&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; NM=&lt;SPAN style="color: #800080;"&gt;"Workers'"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;THEN &lt;/SPAN&gt; D4 ,&lt;/P&gt;&lt;P&gt;&amp;nbsp; ELSE &lt;SPAN style="color: #0000ff;"&gt;WHEN&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;NM=&lt;SPAN style="color: #800080;"&gt;"Motor "&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;THEN&lt;/SPAN&gt;&amp;nbsp; D5 ,&lt;/P&gt;&lt;P&gt;ELSE&amp;nbsp; &lt;SPAN style="color: #0000ff;"&gt;WHEN&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;NM=&lt;SPAN style="color: #800080;"&gt;"Other motor "&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;THEN&lt;/SPAN&gt;&amp;nbsp; D6 ,&lt;/P&gt;&lt;P&gt;ELSE &lt;SPAN style="color: #0000ff;"&gt;WHEN&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;NM=&lt;SPAN style="color: #800080;"&gt;"Marine"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;THEN&lt;/SPAN&gt;&amp;nbsp; D7 ,&lt;/P&gt;&lt;P&gt;ELSE &lt;SPAN style="color: #0000ff;"&gt;WHEN&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;NM=&lt;SPAN style="color: #800080;"&gt;"General "&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;THEN&lt;/SPAN&gt;&amp;nbsp; D8 &lt;/P&gt;&lt;P&gt;ELSE "."&lt;/P&gt;&lt;P&gt;END;&lt;/P&gt;&lt;P&gt;QUIT;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Apr 2012 17:09:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-Create-many-variables-from-one-variable-using-case/m-p/77514#M16787</guid>
      <dc:creator>forumsguy</dc:creator>
      <dc:date>2012-04-10T17:09:49Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL : Create many variables from one variable using case</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-Create-many-variables-from-one-variable-using-case/m-p/77515#M16788</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your code is doing the opposite of your request. You care creating one variable from many variables.&lt;/P&gt;&lt;P&gt;To make many variables you would need many CASE statements.&amp;nbsp; Assuming you want to split copy TPJNL into variables D2,D3,... then use something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;select&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; case when (&lt;SPAN style="font-family: 'courier new', courier;"&gt;NM='Medical') then TPJNL else . end as D2&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; ,case when (NM='Income') then TPJNL else . end as D3&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Apr 2012 17:16:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-Create-many-variables-from-one-variable-using-case/m-p/77515#M16788</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-04-10T17:16:57Z</dc:date>
    </item>
  </channel>
</rss>

