<?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: Resolving an Array in a put statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Resolving-an-Array-in-a-put-statement/m-p/612479#M178728</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/303946"&gt;@ferris1973&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I am struggling to put the value of an array into a put statement&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;&lt;FONT&gt;array newvar [*] var1 var2;&lt;BR /&gt;&amp;nbsp;array oldvar [*] _var1 _var2; &lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do i=1 to dim(newvar);&lt;BR /&gt;&amp;nbsp; newvar(i)=oldvar(i);&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT&gt;&amp;nbsp; if length(oldvar(i)) &amp;gt;10 then put 'ALERT P: ' newvar(I) ' is over 200 characters for subject ' subject;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT&gt;Each time I do this it resolves to value of var1 rather than 'var1'.&lt;/FONT&gt;&lt;/DIV&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That is exactly what you are telling the program to do. Newvar(i) has the value of the oldvar array element. If you want to get the NAME of the variable then you want to use the VNAME function to get the name of the variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Something like:&lt;/P&gt;
&lt;PRE&gt;do i=1 to dim(oldvar);
  varname = Vname(oldvar[i]);
  if length(oldvar(i)) &amp;gt;10 then put 'ALERT P: ' varname ' is over 200 characters for subject ' subject;
end;    &lt;/PRE&gt;
&lt;P&gt;Though how you can tell that the length is over 200 when you are testing for 10 characters is questionable...&lt;/P&gt;</description>
    <pubDate>Tue, 17 Dec 2019 17:53:49 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2019-12-17T17:53:49Z</dc:date>
    <item>
      <title>Resolving an Array in a put statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Resolving-an-Array-in-a-put-statement/m-p/612475#M178725</link>
      <description>&lt;P&gt;I am struggling to put the value of an array into a put statement&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;FONT&gt;array newvar [*] var1 var2;&lt;BR /&gt;&amp;nbsp;array oldvar [*] _var1 _var2; &lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do i=1 to dim(newvar);&lt;BR /&gt;&amp;nbsp; newvar(i)=oldvar(i);&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT&gt;&amp;nbsp; if length(oldvar(i)) &amp;gt;10 then put 'ALERT P: ' newvar(I) ' is over 200 characters for subject ' subject;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT&gt;Each time I do this it resolves to value of var1 rather than 'var1'.&lt;/FONT&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 17 Dec 2019 17:43:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Resolving-an-Array-in-a-put-statement/m-p/612475#M178725</guid>
      <dc:creator>ferris1973</dc:creator>
      <dc:date>2019-12-17T17:43:03Z</dc:date>
    </item>
    <item>
      <title>Re: Resolving an Array in a put statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Resolving-an-Array-in-a-put-statement/m-p/612479#M178728</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/303946"&gt;@ferris1973&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I am struggling to put the value of an array into a put statement&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;&lt;FONT&gt;array newvar [*] var1 var2;&lt;BR /&gt;&amp;nbsp;array oldvar [*] _var1 _var2; &lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do i=1 to dim(newvar);&lt;BR /&gt;&amp;nbsp; newvar(i)=oldvar(i);&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT&gt;&amp;nbsp; if length(oldvar(i)) &amp;gt;10 then put 'ALERT P: ' newvar(I) ' is over 200 characters for subject ' subject;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT&gt;Each time I do this it resolves to value of var1 rather than 'var1'.&lt;/FONT&gt;&lt;/DIV&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That is exactly what you are telling the program to do. Newvar(i) has the value of the oldvar array element. If you want to get the NAME of the variable then you want to use the VNAME function to get the name of the variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Something like:&lt;/P&gt;
&lt;PRE&gt;do i=1 to dim(oldvar);
  varname = Vname(oldvar[i]);
  if length(oldvar(i)) &amp;gt;10 then put 'ALERT P: ' varname ' is over 200 characters for subject ' subject;
end;    &lt;/PRE&gt;
&lt;P&gt;Though how you can tell that the length is over 200 when you are testing for 10 characters is questionable...&lt;/P&gt;</description>
      <pubDate>Tue, 17 Dec 2019 17:53:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Resolving-an-Array-in-a-put-statement/m-p/612479#M178728</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-12-17T17:53:49Z</dc:date>
    </item>
    <item>
      <title>Re: Resolving an Array in a put statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Resolving-an-Array-in-a-put-statement/m-p/612483#M178731</link>
      <description>I will try this thanks! Yes I was using the &amp;gt;10 to make it fire for testing!&lt;BR /&gt;</description>
      <pubDate>Tue, 17 Dec 2019 17:58:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Resolving-an-Array-in-a-put-statement/m-p/612483#M178731</guid>
      <dc:creator>ferris1973</dc:creator>
      <dc:date>2019-12-17T17:58:49Z</dc:date>
    </item>
    <item>
      <title>Re: Resolving an Array in a put statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Resolving-an-Array-in-a-put-statement/m-p/612487#M178733</link>
      <description>&lt;P&gt;You are just writing the value, not the name.&amp;nbsp; You could just add the = to the put statement and SAS will include the variable name. While you are at it why not add the $QUOTE format so it is clearer where the value ends?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  array newvar $20 var1 var2;
  array oldvar $20 _var1 _var2;
  input _var1 _var2;
  subject+1;
  do i=1 to dim(newvar);
    newvar(i)=oldvar(i);
    if length(oldvar(i)) &amp;gt;10 then
       put 'ALERT P: ' newvar(I)= :$quote. 'is over 200 characters for ' subject=
    ;
  end;   
cards;
1 2 
1234567890123 abc
xyz 123456789012
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;ALERT P: var1="1234567890123" is over 200 characters for subject=2
ALERT P: var2="123456789012" is over 200 characters for subject=3
NOTE: The data set WORK.TEST has 3 observations and 6 variables.
&lt;/PRE&gt;</description>
      <pubDate>Tue, 17 Dec 2019 18:09:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Resolving-an-Array-in-a-put-statement/m-p/612487#M178733</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-12-17T18:09:03Z</dc:date>
    </item>
  </channel>
</rss>

