<?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 Looping with variables in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Looping-with-variables/m-p/53582#M14808</link>
    <description>hi&lt;BR /&gt;
&lt;BR /&gt;
i recently started programming in SAS and i have a couple of questions. &lt;BR /&gt;
&lt;BR /&gt;
assuming that i have a couple of variables with a number of observations, how do i write a loop so that a procedure is executed on every variable?&lt;BR /&gt;
&lt;BR /&gt;
for example. i have variables named Y1, Y, .. ,Yn. how do i write a loop so that an &lt;I&gt;if&lt;/I&gt; statement is performed for all the variables. so i don't have to type: &lt;BR /&gt;
&lt;I&gt;&lt;BR /&gt;
if Y1 = x then DELETE;&lt;BR /&gt;
if Y2 = x then DELETE;&lt;BR /&gt;
...&lt;BR /&gt;
if Yn = x then DELETE;&lt;/I&gt;&lt;BR /&gt;
&lt;BR /&gt;
and my second question is if it's possible to print variables from more than one data set using proc print? cus if i have two &lt;I&gt;DATA = &lt;/I&gt; the log tells me &lt;BR /&gt;
&lt;BR /&gt;
&lt;I&gt;WARNING: Ignoring second data set reference&lt;/I&gt;</description>
    <pubDate>Sun, 12 Oct 2008 01:38:44 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2008-10-12T01:38:44Z</dc:date>
    <item>
      <title>Looping with variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Looping-with-variables/m-p/53582#M14808</link>
      <description>hi&lt;BR /&gt;
&lt;BR /&gt;
i recently started programming in SAS and i have a couple of questions. &lt;BR /&gt;
&lt;BR /&gt;
assuming that i have a couple of variables with a number of observations, how do i write a loop so that a procedure is executed on every variable?&lt;BR /&gt;
&lt;BR /&gt;
for example. i have variables named Y1, Y, .. ,Yn. how do i write a loop so that an &lt;I&gt;if&lt;/I&gt; statement is performed for all the variables. so i don't have to type: &lt;BR /&gt;
&lt;I&gt;&lt;BR /&gt;
if Y1 = x then DELETE;&lt;BR /&gt;
if Y2 = x then DELETE;&lt;BR /&gt;
...&lt;BR /&gt;
if Yn = x then DELETE;&lt;/I&gt;&lt;BR /&gt;
&lt;BR /&gt;
and my second question is if it's possible to print variables from more than one data set using proc print? cus if i have two &lt;I&gt;DATA = &lt;/I&gt; the log tells me &lt;BR /&gt;
&lt;BR /&gt;
&lt;I&gt;WARNING: Ignoring second data set reference&lt;/I&gt;</description>
      <pubDate>Sun, 12 Oct 2008 01:38:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Looping-with-variables/m-p/53582#M14808</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-10-12T01:38:44Z</dc:date>
    </item>
    <item>
      <title>Re: Looping with variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Looping-with-variables/m-p/53583#M14809</link>
      <description>You can declare an ARRAY statement with a specific set of SAS variable(s) and iterate over the array with a DO / END loop, as shown below:&lt;BR /&gt;
&lt;BR /&gt;
data _null_;&lt;BR /&gt;
retain charvar1-charvar5 'x';&lt;BR /&gt;
ARRAY acharvar (*) $ charvar1 charvar3 charvar5;&lt;BR /&gt;
do i=1 to dim(acharvar);&lt;BR /&gt;
  if acharvar(i) = 'x' then putlog 'match - ' acharvar(i)= ;&lt;BR /&gt;
end;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
And PROC PRINT cannot be used with more than one data file at a time.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Sun, 12 Oct 2008 17:53:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Looping-with-variables/m-p/53583#M14809</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2008-10-12T17:53:42Z</dc:date>
    </item>
    <item>
      <title>Re: Looping with variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Looping-with-variables/m-p/53584#M14810</link>
      <description>You can define a view thus:&lt;BR /&gt;
&lt;BR /&gt;
DATA TEMP / VIEW=TEMP;&lt;BR /&gt;
 SET FILEA FILEB;&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
PROC PRINT DATA=TEMP;&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
Of course, the two files should have compatible variables etc for this to work.</description>
      <pubDate>Mon, 13 Oct 2008 14:36:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Looping-with-variables/m-p/53584#M14810</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-10-13T14:36:49Z</dc:date>
    </item>
  </channel>
</rss>

