<?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: Multiplying arrays without using a loop in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Multiplying-arrays-without-using-a-loop/m-p/114910#M259251</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Actually the variables are named differently and using Var1-3 is not possible!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let us say,&lt;/P&gt;&lt;P&gt;dollars1-24, units1-24 and packet1-24&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 19 Aug 2013 07:49:04 GMT</pubDate>
    <dc:creator>Kavindra</dc:creator>
    <dc:date>2013-08-19T07:49:04Z</dc:date>
    <item>
      <title>Multiplying arrays without using a loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiplying-arrays-without-using-a-loop/m-p/114909#M259250</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;A very good day!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let us say I have a dataset:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Name| Var1| Var2 | Var3&lt;/P&gt;&lt;P&gt;A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |23&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |25&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |28&lt;/P&gt;&lt;P&gt;B&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |45&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |33&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |32&lt;/P&gt;&lt;P&gt;C&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |23&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |65&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |67&lt;/P&gt;&lt;P&gt;D&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |13&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |14&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |14&lt;/P&gt;&lt;P&gt;E&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |65&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |66&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |69&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Where Name is character and Var1-3 are numeric.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Problem:&lt;/P&gt;&lt;P&gt;If the name is equal to A or B, all the numeric values should be multiplied by 100.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is it possible to do it without looping or arrays. Something of the nature,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If Name IN ("A" "B") then do;&lt;/P&gt;&lt;P&gt;_numeric_ *100;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is just a run of the mill thought and doesn't mean it is right!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;Any other solutions welcome.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Kavindra&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Aug 2013 07:41:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiplying-arrays-without-using-a-loop/m-p/114909#M259250</guid>
      <dc:creator>Kavindra</dc:creator>
      <dc:date>2013-08-19T07:41:45Z</dc:date>
    </item>
    <item>
      <title>Re: Multiplying arrays without using a loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiplying-arrays-without-using-a-loop/m-p/114910#M259251</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Actually the variables are named differently and using Var1-3 is not possible!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let us say,&lt;/P&gt;&lt;P&gt;dollars1-24, units1-24 and packet1-24&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Aug 2013 07:49:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiplying-arrays-without-using-a-loop/m-p/114910#M259251</guid>
      <dc:creator>Kavindra</dc:creator>
      <dc:date>2013-08-19T07:49:04Z</dc:date>
    </item>
    <item>
      <title>Re: Multiplying arrays without using a loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiplying-arrays-without-using-a-loop/m-p/114911#M259252</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What is the reason for asking without looping or arrays? &lt;/P&gt;&lt;P&gt;It are programming elements that should make coding easier.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Looping over records is done automatic. SAS is doing that SQL is doing that.&lt;/P&gt;&lt;P&gt;As it is already happening you do not need to code by yourself.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Arrays are a feature to do a lot of the same without typing it all yourself. &lt;A href="http://support.sas.com/documentation/cdl/en/lrcon/64801/HTML/default/viewer.htm#n1dz2m2a92evwwn15vaikevup5pr.htm" title="http://support.sas.com/documentation/cdl/en/lrcon/64801/HTML/default/viewer.htm#n1dz2m2a92evwwn15vaikevup5pr.htm"&gt;SAS(R) 9.4 Language Reference: Concepts&lt;/A&gt;&lt;/P&gt;&lt;P&gt;There are many automatic ways working with arays or naming conventions (* :&amp;nbsp;&amp;nbsp; Variable lists)&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Aug 2013 08:35:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiplying-arrays-without-using-a-loop/m-p/114911#M259252</guid>
      <dc:creator>jakarman</dc:creator>
      <dc:date>2013-08-19T08:35:15Z</dc:date>
    </item>
    <item>
      <title>Re: Multiplying arrays without using a loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiplying-arrays-without-using-a-loop/m-p/114912#M259253</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Basically the numeric variables are named very diversely. So, there is no way to rename them without tediously writing down their names. So, it would be helpful if it could be done for all numeric variables.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Aug 2013 08:59:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiplying-arrays-without-using-a-loop/m-p/114912#M259253</guid>
      <dc:creator>Kavindra</dc:creator>
      <dc:date>2013-08-19T08:59:51Z</dc:date>
    </item>
    <item>
      <title>Re: Multiplying arrays without using a loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiplying-arrays-without-using-a-loop/m-p/114913#M259254</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This looks a nice reference using the _numeric_ list.&amp;nbsp; &lt;A href="http://www2.sas.com/proceedings/sugi30/242-30.pdf" title="http://www2.sas.com/proceedings/sugi30/242-30.pdf"&gt;http://www2.sas.com/proceedings/sugi30/242-30.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Do not be afraid of array-s. See the allnums usage sample with the dimension automatic supplies. &lt;/P&gt;&lt;P&gt;Some surprise, the 24 number should be a coincidence, possible a common 2 year interval approach.&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Aug 2013 10:17:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiplying-arrays-without-using-a-loop/m-p/114913#M259254</guid>
      <dc:creator>jakarman</dc:creator>
      <dc:date>2013-08-19T10:17:44Z</dc:date>
    </item>
    <item>
      <title>Re: Multiplying arrays without using a loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiplying-arrays-without-using-a-loop/m-p/114914#M259255</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data Have;&lt;BR /&gt;input Name $ Var1 Var2 Var3;&lt;BR /&gt;datalines;&lt;BR /&gt;A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 23&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 25&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 28&lt;BR /&gt;B&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 45&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 33&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 32&lt;BR /&gt;C&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 23&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 65&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 67&lt;BR /&gt;D&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 13&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 14&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 14&lt;BR /&gt;E&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 65&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 66&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 69&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;data Want(drop i);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; set have;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; array x{*} _numeric_;&amp;nbsp;&amp;nbsp; /* all numeric vars */&lt;BR /&gt;&amp;nbsp;&amp;nbsp; if Name IN ("A" "B") then do; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do i=1 to dim(x);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x{i} = 100*x{i};&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; end;&lt;BR /&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Aug 2013 13:10:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiplying-arrays-without-using-a-loop/m-p/114914#M259255</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2013-08-19T13:10:11Z</dc:date>
    </item>
    <item>
      <title>Re: Multiplying arrays without using a loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiplying-arrays-without-using-a-loop/m-p/114915#M259256</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Kavindra,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can use _NUMERIC_ to define an array referencing all numeric variables in the data vector and then loop on that array.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array temp {*} _NUMERIC_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if name in ("A", "B") then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do i=1 to dim(temp);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; temp{i}=temp{i}*100;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; drop i;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It's not quite "without arrays" but it read to me as though your issue was that of getting all of your numeric variables in an array when not knowing all the variables names or, well, not wanting to hard type them all because they are not ranges. I have to agree with Jaap in that you shouldn't restrain yourself not to use arrays. They often provide the easiest solution and figuring out the appropriate syntax to solve your loop issue is what the SAS community/documentation is there for.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, as a possible alternative to obtaining all of your numeric variables names, you can always consider using SASHELP.vcolumn automatic table. Either load the name of the numeric variables in a macro for a proc datasets rename or just to use these macros to build the list of variables for an array statement for example.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Vince&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Eh apparently I got beat to it by Rick while writting up &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt; sorry for duplicate code.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Aug 2013 13:18:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiplying-arrays-without-using-a-loop/m-p/114915#M259256</guid>
      <dc:creator>Vince28_Statcan</dc:creator>
      <dc:date>2013-08-19T13:18:35Z</dc:date>
    </item>
    <item>
      <title>Re: Multiplying arrays without using a loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiplying-arrays-without-using-a-loop/m-p/114916#M259257</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thx Rick Vince,&lt;/P&gt;&lt;P&gt;I was just pulling at Kavindra's mind/brains for the why's and how's the requirements and options with questions and giving some doc's..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Aug 2013 13:29:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiplying-arrays-without-using-a-loop/m-p/114916#M259257</guid>
      <dc:creator>jakarman</dc:creator>
      <dc:date>2013-08-19T13:29:08Z</dc:date>
    </item>
  </channel>
</rss>

