<?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: Creating a conditional variable starting from a non-numerical variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-conditional-variable-starting-from-a-non-numerical/m-p/400295#M97043</link>
    <description>&lt;P&gt;Post your test data as a datastep, follow this post if you don't know how to:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Its very hard for us to be guessing everything, for instance, do you have spaces before or after the text?&amp;nbsp; "ABC " is not the same as "ABC".&amp;nbsp; Also show your code.&lt;/P&gt;</description>
    <pubDate>Mon, 02 Oct 2017 15:01:17 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2017-10-02T15:01:17Z</dc:date>
    <item>
      <title>Creating a conditional variable starting from a non-numerical variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-conditional-variable-starting-from-a-non-numerical/m-p/400261#M97029</link>
      <description>&lt;P&gt;Hello all.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm getting started with SAS and I need a conditional variable starting from a non-numerical variable. My dataset looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;CITY $ var2 var3&lt;/P&gt;&lt;P&gt;London . .&amp;nbsp;&lt;/P&gt;&lt;P&gt;London . .&lt;/P&gt;&lt;P&gt;New York . .&amp;nbsp;&lt;/P&gt;&lt;P&gt;Madrid . .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using the IF THEN command in order to get the system to create a new numerical variable starting from the city names (IF CITY=London THEN CITYNR=1;&amp;nbsp;&lt;SPAN&gt;IF CITY=Madrid THEN CITYNR=2; etc), but I can't bring the code to work. The output table has new columns for CITYNR, LONDON, MADRID, etc, which is of course something I don't want. Just for the sake of it I tried the same command starting from a numerical variable like var2 or var3 and it works.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;What am I getting wrong? Can anyone help me? Thank you so much!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Oct 2017 13:58:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-conditional-variable-starting-from-a-non-numerical/m-p/400261#M97029</guid>
      <dc:creator>LunaMinerva</dc:creator>
      <dc:date>2017-10-02T13:58:53Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a conditional variable starting from a non-numerical variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-conditional-variable-starting-from-a-non-numerical/m-p/400263#M97030</link>
      <description>&lt;P&gt;The logical test&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IF CITY=LONDON&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;tells SAS to compare the CITY var to the LONDON var, so SAS assumes there is an (unitialized) var named LONDON.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You really want to test CITY var against a literal VALUE, as in&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if CITY='LONDON' then .... ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; else if CITY='MADRID' then ....;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Oct 2017 14:03:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-conditional-variable-starting-from-a-non-numerical/m-p/400263#M97030</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2017-10-02T14:03:25Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a conditional variable starting from a non-numerical variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-conditional-variable-starting-from-a-non-numerical/m-p/400265#M97031</link>
      <description>&lt;P&gt;Ok, so I just tried putting the city names between apostrophes and it does work because I'm finally getting the CITYNR column I was looking for with the correct numbers, but I'm also still getting empty columns for each city name. What else am I getting wrong?&lt;/P&gt;</description>
      <pubDate>Mon, 02 Oct 2017 14:08:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-conditional-variable-starting-from-a-non-numerical/m-p/400265#M97031</guid>
      <dc:creator>LunaMinerva</dc:creator>
      <dc:date>2017-10-02T14:08:32Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a conditional variable starting from a non-numerical variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-conditional-variable-starting-from-a-non-numerical/m-p/400291#M97040</link>
      <description>&lt;P&gt;Post the code you are using.&lt;/P&gt;</description>
      <pubDate>Mon, 02 Oct 2017 14:58:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-conditional-variable-starting-from-a-non-numerical/m-p/400291#M97040</guid>
      <dc:creator>HB</dc:creator>
      <dc:date>2017-10-02T14:58:12Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a conditional variable starting from a non-numerical variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-conditional-variable-starting-from-a-non-numerical/m-p/400295#M97043</link>
      <description>&lt;P&gt;Post your test data as a datastep, follow this post if you don't know how to:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Its very hard for us to be guessing everything, for instance, do you have spaces before or after the text?&amp;nbsp; "ABC " is not the same as "ABC".&amp;nbsp; Also show your code.&lt;/P&gt;</description>
      <pubDate>Mon, 02 Oct 2017 15:01:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-conditional-variable-starting-from-a-non-numerical/m-p/400295#M97043</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-10-02T15:01:17Z</dc:date>
    </item>
  </channel>
</rss>

