<?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: Check multiple variables with non-missing values and create new variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Check-multiple-variables-with-non-missing-values-and-create-new/m-p/873421#M345102</link>
    <description>&lt;P&gt;Take advantage of the ability to define arrays with custom lower and upper bounds:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data score_trans_new2;
  set score_trans;
  length vislst $100;
  array values {7:14} var7-var14;
  do  v=lbound(values) to hbound(values);
    if values{v}^=. then vislst=catx(',',vislst,v);
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 02 May 2023 16:02:45 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2023-05-02T16:02:45Z</dc:date>
    <item>
      <title>Check multiple variables with non-missing values and create new variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-multiple-variables-with-non-missing-values-and-create-new/m-p/873406#M345095</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset with multiple score variables (var7 - var14 where 7 represents visit 7) and I am using array to check which variables had non-missing value and I want to create a new variable vislst to store these visit numbers in (e.g. 7,9,10).&lt;/P&gt;&lt;P&gt;Below codes can only store the last non-missing visit number and not the list of visits. I tried first. and retain but not worked yet. Please help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data Score_trans_new;&lt;BR /&gt;set Score_trans;&lt;BR /&gt;length vislst $100.;&lt;BR /&gt;array values[1:8] var7 var8 var9 var10 var11 var12 var13 var14;&lt;BR /&gt;do i=1 to dim(values);&lt;BR /&gt;if not missing(values[i]) then do;&lt;BR /&gt;vislst=substr(vname(values[i]),7,2);&lt;BR /&gt;end;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 02 May 2023 15:35:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-multiple-variables-with-non-missing-values-and-create-new/m-p/873406#M345095</guid>
      <dc:creator>sliaousa</dc:creator>
      <dc:date>2023-05-02T15:35:25Z</dc:date>
    </item>
    <item>
      <title>Re: Check multiple variables with non-missing values and create new variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-multiple-variables-with-non-missing-values-and-create-new/m-p/873413#M345101</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Score_trans;
 var7=1; var8=.; var9=1; var10=1; var11=.; var12=.; var13=.; var14=.;
run; 

data Score_trans_new(drop=i SUB);
 length vislst $100.;
 set Score_trans;
 array values{8} var7-var14;
 vislst='';
 do i=1 to dim(values);
  if not missing(values(i)) then do;
  vislst=strip(vislst)!!' '!!strip(vname(values(i)));
  end;
 end;
 SUB = 'var';
 vislst = transtrn(vislst,SUB,trimn(''));
run;
/* end of program */&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 02 May 2023 15:48:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-multiple-variables-with-non-missing-values-and-create-new/m-p/873413#M345101</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2023-05-02T15:48:36Z</dc:date>
    </item>
    <item>
      <title>Re: Check multiple variables with non-missing values and create new variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-multiple-variables-with-non-missing-values-and-create-new/m-p/873421#M345102</link>
      <description>&lt;P&gt;Take advantage of the ability to define arrays with custom lower and upper bounds:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data score_trans_new2;
  set score_trans;
  length vislst $100;
  array values {7:14} var7-var14;
  do  v=lbound(values) to hbound(values);
    if values{v}^=. then vislst=catx(',',vislst,v);
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 02 May 2023 16:02:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-multiple-variables-with-non-missing-values-and-create-new/m-p/873421#M345102</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2023-05-02T16:02:45Z</dc:date>
    </item>
    <item>
      <title>Re: Check multiple variables with non-missing values and create new variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-multiple-variables-with-non-missing-values-and-create-new/m-p/873461#M345120</link>
      <description>Thank you!</description>
      <pubDate>Tue, 02 May 2023 18:41:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-multiple-variables-with-non-missing-values-and-create-new/m-p/873461#M345120</guid>
      <dc:creator>sliaousa</dc:creator>
      <dc:date>2023-05-02T18:41:43Z</dc:date>
    </item>
  </channel>
</rss>

