<?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: IF statement in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/IF-statement/m-p/72747#M21093</link>
    <description>Hello ArtC,&lt;BR /&gt;
&lt;BR /&gt;
This looked like it would take care of my problem except that even with the OUTPUT; code it still replaces all the data with "0" instead of just plugging in "0" for the missing data file only.&lt;BR /&gt;
&lt;BR /&gt;
Just to clarify what I am trying to do: I got 150 files that is several pages long but I only need this section of the data "Information Criteria" except that some of the files do not have this data. So I would like to plug in "0" for the data files that do not have this information. This way I have for example :Temp_1 with all 4 variables and Temp_1 with the value of "0" for all the variables. &lt;BR /&gt;
&lt;BR /&gt;
Thank you</description>
    <pubDate>Mon, 06 Jun 2011 16:33:11 GMT</pubDate>
    <dc:creator>R_A_G_</dc:creator>
    <dc:date>2011-06-06T16:33:11Z</dc:date>
    <item>
      <title>IF statement</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/IF-statement/m-p/72745#M21091</link>
      <description>Hello,&lt;BR /&gt;
&lt;BR /&gt;
I have a code to read a statement from a text file but sometimes there is no text to read, which in that case I need to insert 0 for each one them. Would someone help me figure out how to do that.&lt;BR /&gt;
&lt;BR /&gt;
Thanks&lt;BR /&gt;
&lt;BR /&gt;
Code:&lt;BR /&gt;
data CDM1.temp_&amp;amp;seed;&lt;BR /&gt;
infile "c:\CDM1\&amp;amp;commandfile..out" truncover;&lt;BR /&gt;
input test $21. @;&lt;BR /&gt;
if test="Information Criteria" then do;&lt;BR /&gt;
 input / / @40 num_fre_par&lt;BR /&gt;
         / @40 akaike5&lt;BR /&gt;
         / @40 bayesian&lt;BR /&gt;
         / @40 sam_siz_adj_bic ;&lt;BR /&gt;
&lt;BR /&gt;
&lt;B&gt;else input num_fre_par=0 akaike5=0 bayesian=0;&lt;/B&gt;   &lt;I&gt; this doesn't give me 0 for each missing statement&lt;/I&gt;&lt;BR /&gt;
 output; &lt;BR /&gt;
 stop;&lt;BR /&gt;
end;&lt;BR /&gt;
drop test;&lt;BR /&gt;
run;</description>
      <pubDate>Sun, 05 Jun 2011 23:58:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/IF-statement/m-p/72745#M21091</guid>
      <dc:creator>R_A_G_</dc:creator>
      <dc:date>2011-06-05T23:58:10Z</dc:date>
    </item>
    <item>
      <title>Re: IF statement</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/IF-statement/m-p/72746#M21092</link>
      <description>I am not sure what you are trying to do here.  Is there only one incoming row? or do you want to issue the STOP only if there is no information?  &lt;BR /&gt;
&lt;BR /&gt;
Let me take a guess and we can refine the answer:&lt;BR /&gt;
[pre]&lt;BR /&gt;
data CDM1.temp_&amp;amp;seed;&lt;BR /&gt;
infile "c:\CDM1\&amp;amp;commandfile..out" truncover;&lt;BR /&gt;
input test $21. @;&lt;BR /&gt;
&lt;BR /&gt;
if test="Information Criteria" then do;&lt;BR /&gt;
   * this is good data - read it;&lt;BR /&gt;
   input / / @40 num_fre_par&lt;BR /&gt;
          / @40 akaike5&lt;BR /&gt;
          / @40 bayesian&lt;BR /&gt;
          / @40 sam_siz_adj_bic ;&lt;BR /&gt;
   output;&lt;BR /&gt;
end;  * add the END;&lt;BR /&gt;
else do;&lt;BR /&gt;
   * set values to missing and stop reading data;&lt;BR /&gt;
   num_fre_par=0; akaike5=0; bayesian=0; &lt;BR /&gt;
   output; &lt;BR /&gt;
   stop;  &lt;BR /&gt;
end;&lt;BR /&gt;
drop test;&lt;BR /&gt;
run; &lt;BR /&gt;
[/pre]</description>
      <pubDate>Mon, 06 Jun 2011 05:38:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/IF-statement/m-p/72746#M21092</guid>
      <dc:creator>ArtC</dc:creator>
      <dc:date>2011-06-06T05:38:22Z</dc:date>
    </item>
    <item>
      <title>Re: IF statement</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/IF-statement/m-p/72747#M21093</link>
      <description>Hello ArtC,&lt;BR /&gt;
&lt;BR /&gt;
This looked like it would take care of my problem except that even with the OUTPUT; code it still replaces all the data with "0" instead of just plugging in "0" for the missing data file only.&lt;BR /&gt;
&lt;BR /&gt;
Just to clarify what I am trying to do: I got 150 files that is several pages long but I only need this section of the data "Information Criteria" except that some of the files do not have this data. So I would like to plug in "0" for the data files that do not have this information. This way I have for example :Temp_1 with all 4 variables and Temp_1 with the value of "0" for all the variables. &lt;BR /&gt;
&lt;BR /&gt;
Thank you</description>
      <pubDate>Mon, 06 Jun 2011 16:33:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/IF-statement/m-p/72747#M21093</guid>
      <dc:creator>R_A_G_</dc:creator>
      <dc:date>2011-06-06T16:33:11Z</dc:date>
    </item>
    <item>
      <title>Re: IF statement</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/IF-statement/m-p/72748#M21094</link>
      <description>You have a couple problems.&lt;BR /&gt;
&lt;BR /&gt;
First your "DO" clause includes the "ELSE" so it never gets executed. You only want an input to clear the hold from the "@".&lt;BR /&gt;
&lt;BR /&gt;
Try Instead:&lt;BR /&gt;
if test="Information Criteria" then do;&lt;BR /&gt;
  input / / @40 num_fre_par&lt;BR /&gt;
  / @40 akaike5&lt;BR /&gt;
  / @40 bayesian&lt;BR /&gt;
  / @40 sam_siz_adj_bic ;&lt;BR /&gt;
end;&lt;BR /&gt;
Else do;&lt;BR /&gt;
  num_fre_par=0; &lt;BR /&gt;
  akaike5=0; &lt;BR /&gt;
  bayesian=0; &lt;BR /&gt;
  input;&lt;BR /&gt;
end;</description>
      <pubDate>Mon, 06 Jun 2011 17:55:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/IF-statement/m-p/72748#M21094</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2011-06-06T17:55:29Z</dc:date>
    </item>
    <item>
      <title>Re: IF statement</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/IF-statement/m-p/72749#M21095</link>
      <description>Sorry but it does not work. It seems like ArtC's should work, if I could make the files keep their value instead of replacing all with "0"-missing. &lt;BR /&gt;
&lt;BR /&gt;
Just to clarify what I am trying to do: I got 150 files that is several pages long but I only need this section of the data "Information Criteria" except that some of the files do not have this data -missing. So I would like to plug in "0" for the data files that do not have this information. This way I have for example :Temp_1 with all 4 variables and Temp_2 with the value of "0" for all the variables. At the end I will end up stacking all these 150 data on top each other in ORDER-that is another issue I am having.&lt;BR /&gt;
&lt;BR /&gt;
Thank you</description>
      <pubDate>Mon, 06 Jun 2011 19:29:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/IF-statement/m-p/72749#M21095</guid>
      <dc:creator>R_A_G_</dc:creator>
      <dc:date>2011-06-06T19:29:49Z</dc:date>
    </item>
    <item>
      <title>Re: IF statement</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/IF-statement/m-p/72750#M21096</link>
      <description>You say that you have 150 'files'.  This data step is processing one file at a time, and it creates one data set at a time.  For a given file what do you want to have happen?  This DATA step creates a single observation data set under certain conditions.  Do you want all 150 files to be concatenated into a single data set - with this 'special condition' being just a row in that data set?</description>
      <pubDate>Tue, 07 Jun 2011 04:11:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/IF-statement/m-p/72750#M21096</guid>
      <dc:creator>ArtC</dc:creator>
      <dc:date>2011-06-07T04:11:30Z</dc:date>
    </item>
    <item>
      <title>Re: IF statement</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/IF-statement/m-p/72751#M21097</link>
      <description>I have a solution If you want.&lt;BR /&gt;
[pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
data temp1;&lt;BR /&gt;
 infile  'c:\log.txt' length=len;&lt;BR /&gt;
 input row $varying200. len;&lt;BR /&gt;
run;&lt;BR /&gt;
data temp1(drop=row);&lt;BR /&gt;
 set temp1 end=last;&lt;BR /&gt;
 retain found 'N';&lt;BR /&gt;
 if scan(row,1) eq 'NOTE:' then do;&lt;BR /&gt;
                                  name=scan(row,2); found='Y';&lt;BR /&gt;
                                  output;&lt;BR /&gt;
                                 end;&lt;BR /&gt;
 if last and found='N' then do;&lt;BR /&gt;
                              name='0';&lt;BR /&gt;
                              output;&lt;BR /&gt;
                            end;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Tue, 07 Jun 2011 05:09:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/IF-statement/m-p/72751#M21097</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-06-07T05:09:28Z</dc:date>
    </item>
  </channel>
</rss>

