<?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 macro with array in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/macro-with-array/m-p/33394#M6517</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you, Michelle, that worked.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Btw, is there a way to have a macro contain a numeric?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And as follow-up to arrays, I am trying to do the following: (1) change missings to 'zzzzz', and then add leading zeros e.g., make '123' be '00123'. All variables are character length 5. However, I get an invalid argument to the input function below. When I don't use arrays, it works fine. I'd appreciate your advice.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Last, I'm running out of disk space. Is there a way to do this without creating two additional sets of variables (i.e., proclistb and proclistc)?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Brent&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let proclist proc1 proc2 proc3;&lt;/P&gt;&lt;P&gt;%let proclistb=proc1b proc2b proc3b;&lt;/P&gt;&lt;P&gt;%let proclistc=proc1c proc2c proc3c;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*change missings to zzzzz, add leading zeros;&lt;/P&gt;&lt;P&gt;data new;&lt;/P&gt;&lt;P&gt;set old;&lt;/P&gt;&lt;P&gt;array a {*} $5 &amp;amp;proclist;&lt;/P&gt;&lt;P&gt;array b {*} $5 &amp;amp;proclistb;&lt;/P&gt;&lt;P&gt;array c {*} $5 &amp;amp;proclistc;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;do j=1 to dim(a);&lt;/P&gt;&lt;P&gt;if a{j}~=' ' then b{j} = a{j}; else b{j}=zzzzz; /* do i need to have it be 'zzzzz' ?*/&lt;/P&gt;&lt;P&gt;c{j} = put(input(b{j},best.),z5.);&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 23 Oct 2011 17:45:00 GMT</pubDate>
    <dc:creator>BrentFulton</dc:creator>
    <dc:date>2011-10-23T17:45:00Z</dc:date>
    <item>
      <title>macro with array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-with-array/m-p/33392#M6515</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear SAS Community,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to use a macro within an array statement. The first set of commands worked, but the second didn't. I'd appreciate your help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Brent Fulton&lt;/P&gt;&lt;P&gt;UC Berkeley&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;THIS WORKED&lt;/P&gt;&lt;P&gt;data new;&lt;/P&gt;&lt;P&gt;set old;&lt;/P&gt;&lt;P&gt;array a {*} $ proc1 proc2 proc3;&lt;/P&gt;&lt;P&gt;array b {*} $ proc1b proc2b proc3b;&lt;/P&gt;&lt;P&gt;do j=1 to dim(a);&lt;/P&gt;&lt;P&gt;b{j} = substr(a{j},1,1); &lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;THIS DIDN'T WORK (it is same as above, except use macro proclist. error was "Expecting a variable length specification.")&lt;/P&gt;&lt;P&gt;%let proclist='proc1 proc2 proc3';&lt;/P&gt;&lt;P&gt;data new;&lt;/P&gt;&lt;P&gt;set old;&lt;/P&gt;&lt;P&gt;array a {*} $ &amp;amp;proclist;&lt;/P&gt;&lt;P&gt;array b {*} $ proc1b proc2b proc3b;&lt;/P&gt;&lt;P&gt;do j=1 to dim(a);&lt;/P&gt;&lt;P&gt;b{j} = substr(a{j},1,1); &lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 23 Oct 2011 05:57:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-with-array/m-p/33392#M6515</guid>
      <dc:creator>BrentFulton</dc:creator>
      <dc:date>2011-10-23T05:57:32Z</dc:date>
    </item>
    <item>
      <title>macro with array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-with-array/m-p/33393#M6516</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi There,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In your %let statement remove the single quotes then it will work. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let proclist=proc1 proc2 proc3;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The reason being is because the macro facility is text and as such you don't need to quote your macro variable values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Michelle&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 23 Oct 2011 09:54:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-with-array/m-p/33393#M6516</guid>
      <dc:creator>MichelleHomes</dc:creator>
      <dc:date>2011-10-23T09:54:37Z</dc:date>
    </item>
    <item>
      <title>macro with array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-with-array/m-p/33394#M6517</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you, Michelle, that worked.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Btw, is there a way to have a macro contain a numeric?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And as follow-up to arrays, I am trying to do the following: (1) change missings to 'zzzzz', and then add leading zeros e.g., make '123' be '00123'. All variables are character length 5. However, I get an invalid argument to the input function below. When I don't use arrays, it works fine. I'd appreciate your advice.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Last, I'm running out of disk space. Is there a way to do this without creating two additional sets of variables (i.e., proclistb and proclistc)?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Brent&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let proclist proc1 proc2 proc3;&lt;/P&gt;&lt;P&gt;%let proclistb=proc1b proc2b proc3b;&lt;/P&gt;&lt;P&gt;%let proclistc=proc1c proc2c proc3c;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*change missings to zzzzz, add leading zeros;&lt;/P&gt;&lt;P&gt;data new;&lt;/P&gt;&lt;P&gt;set old;&lt;/P&gt;&lt;P&gt;array a {*} $5 &amp;amp;proclist;&lt;/P&gt;&lt;P&gt;array b {*} $5 &amp;amp;proclistb;&lt;/P&gt;&lt;P&gt;array c {*} $5 &amp;amp;proclistc;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;do j=1 to dim(a);&lt;/P&gt;&lt;P&gt;if a{j}~=' ' then b{j} = a{j}; else b{j}=zzzzz; /* do i need to have it be 'zzzzz' ?*/&lt;/P&gt;&lt;P&gt;c{j} = put(input(b{j},best.),z5.);&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 23 Oct 2011 17:45:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-with-array/m-p/33394#M6517</guid>
      <dc:creator>BrentFulton</dc:creator>
      <dc:date>2011-10-23T17:45:00Z</dc:date>
    </item>
    <item>
      <title>macro with array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-with-array/m-p/33395#M6518</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You need enclose string literals inside of quotes.&amp;nbsp; Without the quotes SAS will look for a variable with the name zzzzz.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There you are not dealing with macro code at all, just normal SAS syntax. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 23 Oct 2011 18:02:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-with-array/m-p/33395#M6518</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2011-10-23T18:02:02Z</dc:date>
    </item>
    <item>
      <title>macro with array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-with-array/m-p/33396#M6519</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you, Tom. I switched the line in question above to:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if a{j}~=' ' then b{j} = a{j}; else b{j}='zzzzz';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, I still get an invalid argument error to the input function on the next line:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;c{j} = put(input(b{j},best.),z5.);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do you or others have suggestions?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks,&lt;/P&gt;&lt;P&gt;Brent&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 23 Oct 2011 18:19:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-with-array/m-p/33396#M6519</guid>
      <dc:creator>BrentFulton</dc:creator>
      <dc:date>2011-10-23T18:19:23Z</dc:date>
    </item>
    <item>
      <title>Re: macro with array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-with-array/m-p/33397#M6520</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi ... if it's just the PROC variables you want to edit , you can skip the macro variable (yes/no?). &lt;/P&gt;&lt;P&gt;If you just want to vary the number of PROCs, use that number as the macro variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;data old;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;input (proc1 proc2 proc3) (: $5.);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;datalines;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;12345 . 999&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;88 77 .&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;%let n=3;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;*change missings to zzzzz, add leading zeros;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;data nw;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;set old;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;array proc{&amp;amp;n};&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;do j=1 to &amp;amp;n;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp; proc{j} = ifc(^missing(proc(j)), translate(right(proc(j)),'0',' '), 'zzzzz');&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;end;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;drop j;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;proc1&amp;nbsp;&amp;nbsp;&amp;nbsp; proc2&amp;nbsp;&amp;nbsp;&amp;nbsp; proc3&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;12345&amp;nbsp;&amp;nbsp;&amp;nbsp; zzzzz&amp;nbsp;&amp;nbsp;&amp;nbsp; 00999&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;00088&amp;nbsp;&amp;nbsp;&amp;nbsp; 00077&amp;nbsp;&amp;nbsp;&amp;nbsp; zzzzz&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 23 Oct 2011 18:22:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-with-array/m-p/33397#M6520</guid>
      <dc:creator>MikeZdeb</dc:creator>
      <dc:date>2011-10-23T18:22:47Z</dc:date>
    </item>
    <item>
      <title>macro with array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-with-array/m-p/33398#M6521</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; this worked well, Mike, thank you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;best,&lt;/P&gt;&lt;P&gt;Brent&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 23 Oct 2011 20:56:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-with-array/m-p/33398#M6521</guid>
      <dc:creator>BrentFulton</dc:creator>
      <dc:date>2011-10-23T20:56:45Z</dc:date>
    </item>
  </channel>
</rss>

