<?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: Is loop possible here? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Is-loop-possible-here/m-p/50582#M10571</link>
    <description>Hey Janne,&lt;BR /&gt;
 i just saw that part of example code got skipped due to usage of Increment variable i within square brackets , and made last part of code into italic. Here is the fixed one&lt;BR /&gt;
&lt;BR /&gt;
data dx;&lt;BR /&gt;
opprim_lak=.;&lt;BR /&gt;
sluten_lak=.;&lt;BR /&gt;
a_sluten_lak=.;&lt;BR /&gt;
z_opprim_lak=.;  &lt;BR /&gt;
run;&lt;BR /&gt;
data new;&lt;BR /&gt;
        set dx;&lt;BR /&gt;
        array nums{*} opprim_lak--z_opprim_lak;/*first var -- last var*/&lt;BR /&gt;
        do i=1 to hbound(nums);&lt;BR /&gt;
                if nums{i}=. then nums{i}=0;&lt;BR /&gt;
        end;&lt;BR /&gt;
        drop i;&lt;BR /&gt;
run;&lt;BR /&gt;
proc print;run;</description>
    <pubDate>Wed, 01 Jul 2009 13:18:44 GMT</pubDate>
    <dc:creator>SushilNayak</dc:creator>
    <dc:date>2009-07-01T13:18:44Z</dc:date>
    <item>
      <title>Is loop possible here?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-loop-possible-here/m-p/50579#M10568</link>
      <description>If opprim_lak=. then opprim_lak=0; &lt;BR /&gt;
I need to do this 120 times. Do anyone know if there is any shortcut or do I have to copy this 120 times? The variables are in a sequence in the dataset beginning with "opprim_lak" and ending with the last variable "sluten_lak"?</description>
      <pubDate>Wed, 01 Jul 2009 12:37:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-loop-possible-here/m-p/50579#M10568</guid>
      <dc:creator>janne</dc:creator>
      <dc:date>2009-07-01T12:37:16Z</dc:date>
    </item>
    <item>
      <title>Re: Is loop possible here?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-loop-possible-here/m-p/50580#M10569</link>
      <description>Hi Janne,&lt;BR /&gt;
As the variables are in sequence in dataset, beginning with opprim_lak till sluten_lak and all these variables count to 120 variables, you could try making an array of these variables(opprim_lak--z_opprim_lak) and then using a do loop take them all. &lt;BR /&gt;
If these variables are not in sequence then what you could do is, make a macro list using proc sql (where var like '%_lak%') separated by ' ' ( let say macro variable is &amp;amp;dummy) and then  array nums&lt;LI&gt; &amp;amp;dummy;&lt;BR /&gt;
If the dataset has these 120 variables as numeric data types and there is no other numeric type variables in the dataset(there can be character type vriables) then you could use array nums&lt;/LI&gt;&lt;LI&gt; _numeric_;&lt;BR /&gt;
&lt;BR /&gt;
example code: &lt;BR /&gt;
data dx;&lt;BR /&gt;
opprim_lak=.;&lt;BR /&gt;
sluten_lak=.;&lt;BR /&gt;
a_sluten_lak=.;&lt;BR /&gt;
z_opprim_lak=.;&lt;BR /&gt;
run;&lt;BR /&gt;
data new;&lt;BR /&gt;
        set dx;&lt;BR /&gt;
        array nums&lt;/LI&gt;&lt;LI&gt; opprim_lak--z_opprim_lak;&lt;BR /&gt;
        do i=1 to hbound(nums);&lt;BR /&gt;
                if nums&lt;I&gt;=. then nums&lt;I&gt;=0;&lt;BR /&gt;
        end;&lt;BR /&gt;
        drop i;&lt;BR /&gt;
run;&lt;BR /&gt;
proc print;run;&lt;/I&gt;&lt;/I&gt;&lt;/LI&gt;</description>
      <pubDate>Wed, 01 Jul 2009 13:00:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-loop-possible-here/m-p/50580#M10569</guid>
      <dc:creator>SushilNayak</dc:creator>
      <dc:date>2009-07-01T13:00:20Z</dc:date>
    </item>
    <item>
      <title>Re: Is loop possible here?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-loop-possible-here/m-p/50581#M10570</link>
      <description>Thank you very much for your quick response. They are numeric and in a sequence but not the only numeric variables i have. I will try your suggestion.&lt;BR /&gt;
Thanks&lt;BR /&gt;
Janne</description>
      <pubDate>Wed, 01 Jul 2009 13:05:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-loop-possible-here/m-p/50581#M10570</guid>
      <dc:creator>janne</dc:creator>
      <dc:date>2009-07-01T13:05:02Z</dc:date>
    </item>
    <item>
      <title>Re: Is loop possible here?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-loop-possible-here/m-p/50582#M10571</link>
      <description>Hey Janne,&lt;BR /&gt;
 i just saw that part of example code got skipped due to usage of Increment variable i within square brackets , and made last part of code into italic. Here is the fixed one&lt;BR /&gt;
&lt;BR /&gt;
data dx;&lt;BR /&gt;
opprim_lak=.;&lt;BR /&gt;
sluten_lak=.;&lt;BR /&gt;
a_sluten_lak=.;&lt;BR /&gt;
z_opprim_lak=.;  &lt;BR /&gt;
run;&lt;BR /&gt;
data new;&lt;BR /&gt;
        set dx;&lt;BR /&gt;
        array nums{*} opprim_lak--z_opprim_lak;/*first var -- last var*/&lt;BR /&gt;
        do i=1 to hbound(nums);&lt;BR /&gt;
                if nums{i}=. then nums{i}=0;&lt;BR /&gt;
        end;&lt;BR /&gt;
        drop i;&lt;BR /&gt;
run;&lt;BR /&gt;
proc print;run;</description>
      <pubDate>Wed, 01 Jul 2009 13:18:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-loop-possible-here/m-p/50582#M10571</guid>
      <dc:creator>SushilNayak</dc:creator>
      <dc:date>2009-07-01T13:18:44Z</dc:date>
    </item>
    <item>
      <title>Re: Is loop possible here?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-loop-possible-here/m-p/50583#M10572</link>
      <description>Thanks. I used your first suggestion and did like this:&lt;BR /&gt;
&lt;BR /&gt;
array vardvar{117} opbesok -- slutenovrig;&lt;BR /&gt;
do i=1 to 117;&lt;BR /&gt;
if vardvar{i}=. then vardvar{i}=0;&lt;BR /&gt;
end;&lt;BR /&gt;
&lt;BR /&gt;
and that worked:)&lt;BR /&gt;
&lt;BR /&gt;
Saved me a lot of work!</description>
      <pubDate>Wed, 01 Jul 2009 15:04:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-loop-possible-here/m-p/50583#M10572</guid>
      <dc:creator>janne</dc:creator>
      <dc:date>2009-07-01T15:04:35Z</dc:date>
    </item>
  </channel>
</rss>

