<?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: Using an array to string out variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Using-an-array-to-string-out-variables/m-p/752210#M236923</link>
    <description>&lt;P&gt;Here some code addressing what I'm guessing you're asking for.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  array her {*} 8 age gender obesity hlth smoke1 smoke2 smoke3 (6*1);
  output;
  smoke2=.;
  smoke3=99;
  output;
  stop;
run;

proc format;
  value danfm
    1= 'age'
    2= 'gender'
    3= 'obesity'
    4= 'hlth'
    5= 'smoke1'
    6= 'smoke2'
    7= 'smoke3'
  ;

data me;
  set have;
  array her {*} age gender obesity hlth smoke1 smoke2 smoke3;

  do tc=1 to dim(her);
    tn= put (tc,danfm.);
    value=her[tc];
    if not missing(value) then output;
  end;
  drop age gender obesity hlth smoke1 smoke2 smoke3;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 06 Jul 2021 06:40:59 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2021-07-06T06:40:59Z</dc:date>
    <item>
      <title>Using an array to string out variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-an-array-to-string-out-variables/m-p/752179#M236906</link>
      <description>&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to use an array to string out variables in my dataset and create a manuscript table.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can any help me review this code? I want the stringed variable to appear in the order as in the array. The code was not running well.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
value danfm
1= 'age'
2= 'gender'
3= 'obesity'
4= 'hlth'
5= 'smoke1'
6= 'smoke2'
7= 'smoke3'
;
data me; set you;
array her age gender obesity hlth smoke1 smoke2 smoke3;
do over her;
tc=_I_;
tn= put (tc,danfm.);
value=her;
output; end;
data me1; set me; if value ne .; run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jul 2021 01:11:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-an-array-to-string-out-variables/m-p/752179#M236906</guid>
      <dc:creator>ChuksManuel</dc:creator>
      <dc:date>2021-07-06T01:11:18Z</dc:date>
    </item>
    <item>
      <title>Re: Using an array to string out variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-an-array-to-string-out-variables/m-p/752186#M236909</link>
      <description>&lt;P&gt;Reading the documentation on the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsref/p08do6szetrxe2n136ush727sbuo.htm" target="_blank" rel="noopener"&gt;ARRAY statement&lt;/A&gt; will help you get the syntax right.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've no idea what you are trying to do in your program and you don't provide any data to test but this is the correct syntax:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array her (*) age gender obesity hlth smoke1 smoke2 smoke3;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 06 Jul 2021 02:47:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-an-array-to-string-out-variables/m-p/752186#M236909</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2021-07-06T02:47:32Z</dc:date>
    </item>
    <item>
      <title>Re: Using an array to string out variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-an-array-to-string-out-variables/m-p/752208#M236922</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13976"&gt;@SASKiwi&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Reading the documentation on the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsref/p08do6szetrxe2n136ush727sbuo.htm" target="_blank" rel="noopener"&gt;ARRAY statement&lt;/A&gt; will help you get the syntax right.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've no idea what you are trying to do in your program and you don't provide any data to test but this is the correct syntax:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array her (*) age gender obesity hlth smoke1 smoke2 smoke3;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/236266"&gt;@ChuksManuel&lt;/a&gt;: The array statement will be of use only, if all variable have the same type. I doubt that "age" is alphanumeric&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jul 2021 05:35:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-an-array-to-string-out-variables/m-p/752208#M236922</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-07-06T05:35:12Z</dc:date>
    </item>
    <item>
      <title>Re: Using an array to string out variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-an-array-to-string-out-variables/m-p/752210#M236923</link>
      <description>&lt;P&gt;Here some code addressing what I'm guessing you're asking for.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  array her {*} 8 age gender obesity hlth smoke1 smoke2 smoke3 (6*1);
  output;
  smoke2=.;
  smoke3=99;
  output;
  stop;
run;

proc format;
  value danfm
    1= 'age'
    2= 'gender'
    3= 'obesity'
    4= 'hlth'
    5= 'smoke1'
    6= 'smoke2'
    7= 'smoke3'
  ;

data me;
  set have;
  array her {*} age gender obesity hlth smoke1 smoke2 smoke3;

  do tc=1 to dim(her);
    tn= put (tc,danfm.);
    value=her[tc];
    if not missing(value) then output;
  end;
  drop age gender obesity hlth smoke1 smoke2 smoke3;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 06 Jul 2021 06:40:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-an-array-to-string-out-variables/m-p/752210#M236923</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-07-06T06:40:59Z</dc:date>
    </item>
    <item>
      <title>Re: Using an array to string out variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-an-array-to-string-out-variables/m-p/752217#M236926</link>
      <description>&lt;P&gt;Thank you. That's exactly what i wanted to do&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jul 2021 07:12:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-an-array-to-string-out-variables/m-p/752217#M236926</guid>
      <dc:creator>ChuksManuel</dc:creator>
      <dc:date>2021-07-06T07:12:39Z</dc:date>
    </item>
  </channel>
</rss>

