<?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 programming arrays with part character variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/programming-arrays-with-part-character-variables/m-p/424175#M104423</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using SAS 9.4 full edition via a virtual desktop. I have 71 co-morbidities and would like to find the most frequent ones.&amp;nbsp; I have shown 3 examples of below of how the variables are coded and then tried to code the array with these 3 example comorbidities. They aren't numbered 1-3 but rather have character coding that distinguish each comorbidity. Do I take the numbers out of the array?&amp;nbsp; Do I have to rename all of the variables?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;CM_PULMCIRC&lt;BR /&gt;CM_RENLFAIL&lt;BR /&gt;CM_LIVER&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want; set have;
array CM_' ' [3] CM_' '1-CM_' '3;   
do i=1 to 3;
   if CM_' ' [i] &amp;gt; ' ' then do;
      diagnosis = CM_' '[i];
	output;
   end;
end;
keep diagnosis;
run;
proc freq order=freq; tables diagnosis; run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;I&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 31 Dec 2017 18:53:06 GMT</pubDate>
    <dc:creator>lmyers2</dc:creator>
    <dc:date>2017-12-31T18:53:06Z</dc:date>
    <item>
      <title>programming arrays with part character variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/programming-arrays-with-part-character-variables/m-p/424175#M104423</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using SAS 9.4 full edition via a virtual desktop. I have 71 co-morbidities and would like to find the most frequent ones.&amp;nbsp; I have shown 3 examples of below of how the variables are coded and then tried to code the array with these 3 example comorbidities. They aren't numbered 1-3 but rather have character coding that distinguish each comorbidity. Do I take the numbers out of the array?&amp;nbsp; Do I have to rename all of the variables?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;CM_PULMCIRC&lt;BR /&gt;CM_RENLFAIL&lt;BR /&gt;CM_LIVER&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want; set have;
array CM_' ' [3] CM_' '1-CM_' '3;   
do i=1 to 3;
   if CM_' ' [i] &amp;gt; ' ' then do;
      diagnosis = CM_' '[i];
	output;
   end;
end;
keep diagnosis;
run;
proc freq order=freq; tables diagnosis; run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;I&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 31 Dec 2017 18:53:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/programming-arrays-with-part-character-variables/m-p/424175#M104423</guid>
      <dc:creator>lmyers2</dc:creator>
      <dc:date>2017-12-31T18:53:06Z</dc:date>
    </item>
    <item>
      <title>Re: programming arrays with part character variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/programming-arrays-with-part-character-variables/m-p/424177#M104425</link>
      <description>&lt;P&gt;You could use:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data want; set have;
  array _CM[3] &lt;SPAN&gt;CM_PULMCIRC &lt;/SPAN&gt;&lt;SPAN&gt;CM_RENLFAIL &lt;/SPAN&gt;&lt;SPAN&gt;CM_LIVER&lt;/SPAN&gt;;   
  do i=1 to 3;
     if not missing(_CM[i]) then do;
        diagnosis = _CM[i];
        output;
     end;
  end;
  keep diagnosis;
run;

proc freq order=freq; tables diagnosis; run;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note: (12/31/2017 5:55pm) Removed an underscore that was inadvertently left in the array name. However, if you are interested in the variable names (as&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt;&amp;nbsp;mentioned), then change&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;diagnosis = _CM[i];&lt;/PRE&gt;
&lt;P&gt;to&lt;/P&gt;
&lt;PRE&gt;diagnosis = vname(_CM[i]);&lt;/PRE&gt;
&lt;P&gt;as he suggested.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 31 Dec 2017 22:59:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/programming-arrays-with-part-character-variables/m-p/424177#M104425</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-12-31T22:59:09Z</dc:date>
    </item>
    <item>
      <title>Re: programming arrays with part character variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/programming-arrays-with-part-character-variables/m-p/424185#M104432</link>
      <description>&lt;P&gt;Or rather&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;diagnosis = vname(_CM[i]);&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 31 Dec 2017 21:40:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/programming-arrays-with-part-character-variables/m-p/424185#M104432</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-12-31T21:40:57Z</dc:date>
    </item>
    <item>
      <title>Re: programming arrays with part character variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/programming-arrays-with-part-character-variables/m-p/424191#M104438</link>
      <description>&lt;P&gt;Your question is a little confusing.&amp;nbsp; You talk about how the variables are coded but I think you meant how they are named.&amp;nbsp; How a variable is coded means the type, length and list or type of valid values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have a series of variables that all start with the same characters you can use a colon ( : ) wildcard in the variable list for your array definition.&amp;nbsp; Just make sure that they are all of the same type (ie coded the same way).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use the DIM() function to find out how many variables are in the array.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  array _CM CM_: ;
  do i=1 to dim(_cm);
    if not missing(_cm(i)) then do;
      diagnosis = _cm(i);
      output;
    end;
  end;
keep diagnosis;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Jan 2018 03:05:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/programming-arrays-with-part-character-variables/m-p/424191#M104438</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-01-01T03:05:29Z</dc:date>
    </item>
  </channel>
</rss>

