<?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: New variable from multiple variable conditions in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/New-variable-from-multiple-variable-conditions/m-p/795963#M255372</link>
    <description>The data file I received already had these variables with these names. The names are not giving me issues and everything is running correctly, I'm asking for a more efficient way of creating the new variable I am asking about.</description>
    <pubDate>Sun, 13 Feb 2022 23:18:21 GMT</pubDate>
    <dc:creator>abrice520</dc:creator>
    <dc:date>2022-02-13T23:18:21Z</dc:date>
    <item>
      <title>New variable from multiple variable conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-variable-from-multiple-variable-conditions/m-p/795961#M255370</link>
      <description>&lt;P&gt;The dataset I'm using has an individual variable for each phecode such as "X250.12, X250.13, X250.14...." which has "TRUE" or "FALSE" depending on whether each observation (patient) has any of these diagnoses.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to create a new variable called "Diabetes" that includes all the observations that say "true" for at least one of these variables (X250.12, X250.13, X250.14...). I know there is an easier way of doing this besides what I have attempted here but I can't remember for the life of me:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;IF X250= "TRUE" THEN Diabetes= 1;
IF X250.1= "TRUE" THEN Diabetes= 1;
IF X250.11= "TRUE" THEN Diabetes=1;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thank you!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 13 Feb 2022 22:19:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-variable-from-multiple-variable-conditions/m-p/795961#M255370</guid>
      <dc:creator>abrice520</dc:creator>
      <dc:date>2022-02-13T22:19:02Z</dc:date>
    </item>
    <item>
      <title>Re: New variable from multiple variable conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-variable-from-multiple-variable-conditions/m-p/795962#M255371</link>
      <description>&lt;P&gt;X250.1 is not a valid variable NAME.&lt;/P&gt;
&lt;P&gt;You can have a character variable with a VALUE of 'X250.1'.&lt;/P&gt;</description>
      <pubDate>Sun, 13 Feb 2022 22:33:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-variable-from-multiple-variable-conditions/m-p/795962#M255371</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-02-13T22:33:37Z</dc:date>
    </item>
    <item>
      <title>Re: New variable from multiple variable conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-variable-from-multiple-variable-conditions/m-p/795963#M255372</link>
      <description>The data file I received already had these variables with these names. The names are not giving me issues and everything is running correctly, I'm asking for a more efficient way of creating the new variable I am asking about.</description>
      <pubDate>Sun, 13 Feb 2022 23:18:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-variable-from-multiple-variable-conditions/m-p/795963#M255372</guid>
      <dc:creator>abrice520</dc:creator>
      <dc:date>2022-02-13T23:18:21Z</dc:date>
    </item>
    <item>
      <title>Re: New variable from multiple variable conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-variable-from-multiple-variable-conditions/m-p/795964#M255373</link>
      <description>&lt;P&gt;Like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DIABETES = index(catt(of X250:), 'TRUE')&amp;gt;0;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 13 Feb 2022 23:47:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-variable-from-multiple-variable-conditions/m-p/795964#M255373</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2022-02-13T23:47:59Z</dc:date>
    </item>
    <item>
      <title>Re: New variable from multiple variable conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-variable-from-multiple-variable-conditions/m-p/795980#M255380</link>
      <description>&lt;P&gt;There are times when data supplied really needs to be cleaned up for use. I suspect this is one of the occasions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First, if the variable names are actually X250.1 then you reference them incorrectly. To have any character other than letter, digit and the _ character in a SAS variable name you have to use "name literal" construction and would reference the variable that appears like that as "X250.1"n the quotes and the n immediately following tells SAS you intend to use that string as variable name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second, data with text "True" and "False" is awkward. It is better for a number of reasons to have numeric 1/0 coded values. SAS will use 1 as "True" and 0 as "False".&lt;/P&gt;
&lt;P&gt;Then you could code such as&lt;/P&gt;
&lt;PRE&gt;Diabetes = (max(list the variable names here separated by commas) = 1 );&lt;/PRE&gt;
&lt;P&gt;SAS will return the result of a comparison as 1/0.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you make the variable names standard SAS names such as X250_1 instead of X205.1 then the above would allow use of variable lists such as&lt;/P&gt;
&lt;PRE&gt;Diabetes = ( max(of x250:)=1);&lt;/PRE&gt;
&lt;P&gt;The colon after the X250 creates a variable list that would use all of the variable names starting with X250.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Feb 2022 03:49:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-variable-from-multiple-variable-conditions/m-p/795980#M255380</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-02-14T03:49:23Z</dc:date>
    </item>
    <item>
      <title>Re: New variable from multiple variable conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-variable-from-multiple-variable-conditions/m-p/795981#M255381</link>
      <description>Yes! Thank you so much!</description>
      <pubDate>Mon, 14 Feb 2022 03:52:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-variable-from-multiple-variable-conditions/m-p/795981#M255381</guid>
      <dc:creator>abrice520</dc:creator>
      <dc:date>2022-02-14T03:52:28Z</dc:date>
    </item>
  </channel>
</rss>

