<?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: Array outside the data statement? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Array-outside-the-data-statement/m-p/176349#M45231</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yep.&amp;nbsp; As an explanation, the data _null_ is just a datastep.&amp;nbsp; It reads from the SAS metadata tables, in this case column deifnitions ones, taking data with libname of WORK and dataset name of TEST.&amp;nbsp; This returns a set of rows which detail all the variables in that dataset.&amp;nbsp; Then for each row (as a datastep is a loop in itself), it generates a SAS code step of the proc sgpanel, replacing the ||name|| (well concatenating the strings) with the variable name in the current row of execution.&amp;nbsp; Hence the proc sgpanel gets replicated for every row returned from the where clause.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 19 Nov 2014 08:51:06 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2014-11-19T08:51:06Z</dc:date>
    <item>
      <title>Array outside the data statement?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Array-outside-the-data-statement/m-p/176344#M45226</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So is there a way to make an array work outside of the data statement?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So basically I have to run this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have to run the following macro for 200 variables: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;%somemacro(var);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;proc sgpanel data=dataset;&lt;/P&gt;&lt;P&gt;&amp;nbsp; panelby&amp;nbsp; visit/rows=1 columns=3 spacing=5 novarname;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; vbox &amp;amp;var / category=subgrp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; rowaxis values=(0 to 100 by 20);&lt;/P&gt;&lt;P&gt;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;%mend &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;somemacro;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The variables are not in numerical order so I can't do a regular do loop. For example a few variables: race, aduPH, BMI)...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I thought an array would be helpful for this situation but I I think it is only for the data statement. SO I am wondering if there is a more efficient solution?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is what I have tried:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;array adu{*} race bmi aduPH aduFEEL aduVIEW aduSPORT;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;do i=1 to dim(adu);&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp; %somemacro(adu(i));&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;end;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Nov 2014 16:06:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Array-outside-the-data-statement/m-p/176344#M45226</guid>
      <dc:creator>Tpham</dc:creator>
      <dc:date>2014-11-18T16:06:55Z</dc:date>
    </item>
    <item>
      <title>Re: Array outside the data statement?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Array-outside-the-data-statement/m-p/176345#M45227</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Lots of options there.&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do I="race","bmi","aduPH"....;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute('%someone ('||strip(I)||');');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;More importantly, if you are able to do the same thing on all those variables, why would you need a macro at all? &lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute('VLIST',"race bmi aduph...");&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array adu{*} &amp;amp;vlist.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Many ways to achieve the same thing, but need to know inputs/outputs.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Nov 2014 16:14:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Array-outside-the-data-statement/m-p/176345#M45227</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-11-18T16:14:05Z</dc:date>
    </item>
    <item>
      <title>Re: Array outside the data statement?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Array-outside-the-data-statement/m-p/176346#M45228</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Basically I am running 200 boxplots.. So I have all the variable name in a list, since I added them in the keep statement in my dataset)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this is the macro:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;%somemacro(var);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;proc sgpanel data=dataset;&lt;/P&gt;&lt;P&gt;&amp;nbsp; panelby&amp;nbsp; visit/rows=1 columns=3 spacing=5 novarname;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; vbox &amp;amp;var / category=subgrp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; rowaxis values=(0 to 100 by 20);&lt;/P&gt;&lt;P&gt;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;%mend &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;somemacro;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Nov 2014 16:46:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Array-outside-the-data-statement/m-p/176346#M45228</guid>
      <dc:creator>Tpham</dc:creator>
      <dc:date>2014-11-18T16:46:34Z</dc:date>
    </item>
    <item>
      <title>Re: Array outside the data statement?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Array-outside-the-data-statement/m-p/176347#M45229</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok, so assuming WORK.TEST holds each of those variables you want to run box plots on:&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set sashelp.vcolumns (where=(libname="WORK" and memname="TEST"));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute('proc sgpanel data=work.test;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; panelby&amp;nbsp; visit/rows=1 columns=3 spacing=5 novarname;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; vbox '||name||' / category=subgrp;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rowaxis values=(0 to 100 by 20);&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;');&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This will generate a proc sgpanel for each variable in work.test.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Nov 2014 18:06:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Array-outside-the-data-statement/m-p/176347#M45229</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-11-18T18:06:42Z</dc:date>
    </item>
    <item>
      <title>Re: Array outside the data statement?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Array-outside-the-data-statement/m-p/176348#M45230</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for this.. so with this, I can change the libname and the memname with my active dataset right?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And with the call execute, will this run the sgpanel for all the variables in the dataset, since there is no "list" in dataset?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Nov 2014 18:10:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Array-outside-the-data-statement/m-p/176348#M45230</guid>
      <dc:creator>Tpham</dc:creator>
      <dc:date>2014-11-18T18:10:25Z</dc:date>
    </item>
    <item>
      <title>Re: Array outside the data statement?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Array-outside-the-data-statement/m-p/176349#M45231</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yep.&amp;nbsp; As an explanation, the data _null_ is just a datastep.&amp;nbsp; It reads from the SAS metadata tables, in this case column deifnitions ones, taking data with libname of WORK and dataset name of TEST.&amp;nbsp; This returns a set of rows which detail all the variables in that dataset.&amp;nbsp; Then for each row (as a datastep is a loop in itself), it generates a SAS code step of the proc sgpanel, replacing the ||name|| (well concatenating the strings) with the variable name in the current row of execution.&amp;nbsp; Hence the proc sgpanel gets replicated for every row returned from the where clause.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Nov 2014 08:51:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Array-outside-the-data-statement/m-p/176349#M45231</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-11-19T08:51:06Z</dc:date>
    </item>
  </channel>
</rss>

