<?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 Array in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Array/m-p/68365#M19578</link>
    <description>Data l;&lt;BR /&gt;
input amt number no;&lt;BR /&gt;
cards;&lt;BR /&gt;
78797 879 1&lt;BR /&gt;
1215   756 2&lt;BR /&gt;
12125 963  3&lt;BR /&gt;
145    782   4&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
1245  712  160&lt;BR /&gt;
254    740  161&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
I want to pass them into macro vaiables like if No=1 then amt should &lt;BR /&gt;
if no=1 call symput('A1',amt) ;&lt;BR /&gt;
if no=1 call symput('B1',number);&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
&lt;BR /&gt;
if no=161 call symput('A161',amt) ;&lt;BR /&gt;
if no=161 call symput('B161',number);&lt;BR /&gt;
i want to do for all the obs as i am having many obs any one can help by using array.I wnat all these macro variables as i wnat to do multipilcation based on No.&lt;BR /&gt;
if no=1 then amt=amt+3 and number=number+3*.30;&lt;BR /&gt;
so i need these macro for every obs</description>
    <pubDate>Mon, 30 Aug 2010 09:32:43 GMT</pubDate>
    <dc:creator>R_Win</dc:creator>
    <dc:date>2010-08-30T09:32:43Z</dc:date>
    <item>
      <title>Array</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Array/m-p/68365#M19578</link>
      <description>Data l;&lt;BR /&gt;
input amt number no;&lt;BR /&gt;
cards;&lt;BR /&gt;
78797 879 1&lt;BR /&gt;
1215   756 2&lt;BR /&gt;
12125 963  3&lt;BR /&gt;
145    782   4&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
1245  712  160&lt;BR /&gt;
254    740  161&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
I want to pass them into macro vaiables like if No=1 then amt should &lt;BR /&gt;
if no=1 call symput('A1',amt) ;&lt;BR /&gt;
if no=1 call symput('B1',number);&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
&lt;BR /&gt;
if no=161 call symput('A161',amt) ;&lt;BR /&gt;
if no=161 call symput('B161',number);&lt;BR /&gt;
i want to do for all the obs as i am having many obs any one can help by using array.I wnat all these macro variables as i wnat to do multipilcation based on No.&lt;BR /&gt;
if no=1 then amt=amt+3 and number=number+3*.30;&lt;BR /&gt;
so i need these macro for every obs</description>
      <pubDate>Mon, 30 Aug 2010 09:32:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Array/m-p/68365#M19578</guid>
      <dc:creator>R_Win</dc:creator>
      <dc:date>2010-08-30T09:32:43Z</dc:date>
    </item>
    <item>
      <title>Re: Array</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Array/m-p/68366#M19579</link>
      <description>You should explain why you think that creating that many macro variables is necessary. The macro-variables name can be created by appending the dataset variable "no" to the appropriate letter.&lt;BR /&gt;
[pre]data _null_;&lt;BR /&gt;
    set yourdata;&lt;BR /&gt;
    call symput(cats('A', no), amt);&lt;BR /&gt;
    call symput(cats('B', no), number);&lt;BR /&gt;
run;[/pre]

Message was edited by: andreas_lds</description>
      <pubDate>Mon, 30 Aug 2010 11:19:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Array/m-p/68366#M19579</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2010-08-30T11:19:28Z</dc:date>
    </item>
    <item>
      <title>Re: Array</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Array/m-p/68367#M19580</link>
      <description>Hi:&lt;BR /&gt;
I'm still not convinced that you need a macro. I agree with Andreas. There are many techniques available to achieve your stated goal: "I want all these macro variables as i want to do multiplication based on No.&lt;BR /&gt;
if no=1 then amt=amt+3 and number=number+3*.30;"&lt;BR /&gt;
          &lt;BR /&gt;
Consider the following program, that uses a FORMAT to create a variable called MULT -- based on the variable AGE -- when AGE is 11, MULT will be 2; when AGE is 13, MULT will be 6, etc:&lt;BR /&gt;
[pre]&lt;BR /&gt;
proc format;&lt;BR /&gt;
  value amult 11=2&lt;BR /&gt;
              12=4&lt;BR /&gt;
              13=6&lt;BR /&gt;
              14=8&lt;BR /&gt;
              15=10&lt;BR /&gt;
              16=12;&lt;BR /&gt;
run;&lt;BR /&gt;
                             &lt;BR /&gt;
data class;&lt;BR /&gt;
  set sashelp.class;&lt;BR /&gt;
  mult = input(put(age,2.0),amult.);&lt;BR /&gt;
  newnum = height * mult;&lt;BR /&gt;
  put age= mult= newnum=;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
                    &lt;BR /&gt;
You probably wouldn't need a format if there was some logic behind how NO=1 turned into a multiplier of 3. But even so, making a lookup list with PROC FORMAT is easier than writing a macro program when you don't need one.&lt;BR /&gt;
 &lt;BR /&gt;
Is there other processing that you are not explaining??? The title of your post was "Array", but you jumped past arrays straight into macro variables. Having numbered macro variables is NOT the same thing as building an array and using numbered macro variables in place of an array is probably not a good idea. At this point, however, I don't understand the need for either arrays or macro variables.&lt;BR /&gt;
&lt;BR /&gt;
cynthia</description>
      <pubDate>Mon, 30 Aug 2010 15:49:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Array/m-p/68367#M19580</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-08-30T15:49:46Z</dc:date>
    </item>
  </channel>
</rss>

