<?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: Skipping Invalid Lines in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Skipping-Invalid-Lines/m-p/691956#M210685</link>
    <description>&lt;P&gt;It seems this will be useful for R CSVs, which put NAs for missings. Thanks.&lt;/P&gt;</description>
    <pubDate>Thu, 15 Oct 2020 20:08:20 GMT</pubDate>
    <dc:creator>Junyong</dc:creator>
    <dc:date>2020-10-15T20:08:20Z</dc:date>
    <item>
      <title>Skipping Invalid Lines</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Skipping-Invalid-Lines/m-p/691945#M210677</link>
      <description>&lt;P&gt;This MWE produces too many &lt;CODE&gt;invalid data note&lt;/CODE&gt;s due to some occasional &lt;CODE&gt;null&lt;/CODE&gt;s as follows.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data irx;
	infile 'https://query1.finance.yahoo.com/v7/finance/download/^irx
?period1=-9999999999&amp;amp;period2=9999999999' url firstobs=2 dsd truncover;
	input date yymmdd10. +1 open hi lo close adj vol;
	if adj&amp;gt;. then output;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;and the file is&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Date,Open,High,Low,Close,Adj Close,Volume
1960-01-04,4.520000,4.520000,4.520000,4.520000,4.520000,0
1960-01-05,4.550000,4.550000,4.550000,4.550000,4.550000,0
1960-01-06,4.680000,4.680000,4.680000,4.680000,4.680000,0
1960-01-07,4.630000,4.630000,4.630000,4.630000,4.630000,0
1960-01-08,4.590000,4.590000,4.590000,4.590000,4.590000,0
1960-01-10,null,null,null,null,null,null
1960-01-11,4.540000,4.540000,4.540000,4.540000,4.540000,0
1960-01-12,4.540000,4.540000,4.540000,4.540000,4.540000,0
1960-01-13,4.560000,4.560000,4.560000,4.560000,4.560000,0
1960-01-14,4.510000,4.510000,4.510000,4.510000,4.510000,0
1960-01-15,4.490000,4.490000,4.490000,4.490000,4.490000,0
1960-01-17,null,null,null,null,null,null
1960-01-18,4.370000,4.370000,4.370000,4.370000,4.370000,0
1960-01-19,4.310000,4.310000,4.310000,4.310000,4.310000,0
1960-01-20,4.300000,4.300000,4.300000,4.300000,4.300000,0
1960-01-21,4.270000,4.270000,4.270000,4.270000,4.270000,0
1960-01-22,4.120000,4.120000,4.120000,4.120000,4.120000,0
1960-01-24,null,null,null,null,null,null
1960-01-25,4.120000,4.120000,4.120000,4.120000,4.120000,0
1960-01-26,4.040000,4.040000,4.040000,4.040000,4.040000,0
1960-01-27,3.990000,3.990000,3.990000,3.990000,3.990000,0
1960-01-28,3.920000,3.920000,3.920000,3.920000,3.920000,0
1960-01-29,3.990000,3.990000,3.990000,3.990000,3.990000,0
1960-01-31,null,null,null,null,null,null&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Can I skip these unnecessary observations, instead of reading all and delete them?&lt;/P&gt;</description>
      <pubDate>Thu, 15 Oct 2020 19:26:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Skipping-Invalid-Lines/m-p/691945#M210677</guid>
      <dc:creator>Junyong</dc:creator>
      <dc:date>2020-10-15T19:26:25Z</dc:date>
    </item>
    <item>
      <title>Re: Skipping Invalid Lines</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Skipping-Invalid-Lines/m-p/691947#M210678</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if _error_=0 and adj&amp;gt;.; /*please try*/&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 15 Oct 2020 19:28:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Skipping-Invalid-Lines/m-p/691947#M210678</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-10-15T19:28:19Z</dc:date>
    </item>
    <item>
      <title>Re: Skipping Invalid Lines</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Skipping-Invalid-Lines/m-p/691949#M210680</link>
      <description>&lt;P&gt;This code also reads all the observations first and then removes the missing observations. Can I not read and completely skip the lines containing the &lt;CODE&gt;null&lt;/CODE&gt;s? For example, I tried the following but failed.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data irx;
	infile 'https://query1.finance.yahoo.com/v7/finance/download/^irx
?period1=-9999999999&amp;amp;period2=9999999999' url firstobs=2 dsd truncover;
	if find(_infile_,"null")=0 then input date yymmdd10. +1 open hi lo close adj vol;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 15 Oct 2020 19:42:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Skipping-Invalid-Lines/m-p/691949#M210680</guid>
      <dc:creator>Junyong</dc:creator>
      <dc:date>2020-10-15T19:42:57Z</dc:date>
    </item>
    <item>
      <title>Re: Skipping Invalid Lines</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Skipping-Invalid-Lines/m-p/691950#M210681</link>
      <description>&lt;P&gt;Ah I see what you mean. How about-&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
 input @;
 if index(_infile_,'null')=0;
 input var   :mmddyy10.;
  cards;
 null
 06/21/1982
 07/21/1982
 null
 ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The above doesn't read records from buffer to PDV. Would that suffice?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Testing your sample-&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data test;
infile cards dsd firstobs=2;
input @;
if index(_infile_,'null')=0;
input date yymmdd10. +1 open hi lo close adj vol;
cards;
Date,Open,High,Low,Close,Adj Close,Volume
1960-01-04,4.520000,4.520000,4.520000,4.520000,4.520000,0
1960-01-05,4.550000,4.550000,4.550000,4.550000,4.550000,0
1960-01-06,4.680000,4.680000,4.680000,4.680000,4.680000,0
1960-01-07,4.630000,4.630000,4.630000,4.630000,4.630000,0
1960-01-08,4.590000,4.590000,4.590000,4.590000,4.590000,0
1960-01-10,null,null,null,null,null,null
1960-01-11,4.540000,4.540000,4.540000,4.540000,4.540000,0
1960-01-12,4.540000,4.540000,4.540000,4.540000,4.540000,0
1960-01-13,4.560000,4.560000,4.560000,4.560000,4.560000,0
1960-01-14,4.510000,4.510000,4.510000,4.510000,4.510000,0
1960-01-15,4.490000,4.490000,4.490000,4.490000,4.490000,0
1960-01-17,null,null,null,null,null,null
1960-01-18,4.370000,4.370000,4.370000,4.370000,4.370000,0
1960-01-19,4.310000,4.310000,4.310000,4.310000,4.310000,0
1960-01-20,4.300000,4.300000,4.300000,4.300000,4.300000,0
1960-01-21,4.270000,4.270000,4.270000,4.270000,4.270000,0
1960-01-22,4.120000,4.120000,4.120000,4.120000,4.120000,0
1960-01-24,null,null,null,null,null,null
1960-01-25,4.120000,4.120000,4.120000,4.120000,4.120000,0
1960-01-26,4.040000,4.040000,4.040000,4.040000,4.040000,0
1960-01-27,3.990000,3.990000,3.990000,3.990000,3.990000,0
1960-01-28,3.920000,3.920000,3.920000,3.920000,3.920000,0
1960-01-29,3.990000,3.990000,3.990000,3.990000,3.990000,0
1960-01-31,null,null,null,null,null,null
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 15 Oct 2020 19:47:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Skipping-Invalid-Lines/m-p/691950#M210681</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-10-15T19:47:49Z</dc:date>
    </item>
    <item>
      <title>Re: Skipping Invalid Lines</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Skipping-Invalid-Lines/m-p/691951#M210682</link>
      <description>&lt;P&gt;Try the "&lt;EM&gt;subsetting if"&lt;/EM&gt; rather than "If Then"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;979  data test;
980  infile cards dsd firstobs=2;
981  input @;
982  if index(_infile_,'null')=0;
983  input date yymmdd10. +1 open hi lo close adj vol;
984  cards;

NOTE: The data set WORK.TEST has 20 observations and 7 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds
&lt;/PRE&gt;</description>
      <pubDate>Thu, 15 Oct 2020 19:56:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Skipping-Invalid-Lines/m-p/691951#M210682</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-10-15T19:56:38Z</dc:date>
    </item>
    <item>
      <title>Re: Skipping Invalid Lines</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Skipping-Invalid-Lines/m-p/691952#M210683</link>
      <description>&lt;P&gt;I like using custom informat to handle these conditions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
  invalue myfmt "null" = .
                default = 10.5;
run;

data want;
  infile datalines firstobs=2 dsd truncover;
  informat open hi lo close adj vol myfmt.;
  input date yymmdd10. +1 open hi lo close adj vol;
	if adj&amp;gt;. then output;
datalines;
Date,Open,High,Low,Close,Adj Close,Volume
1960-01-04,4.520000,4.520000,4.520000,4.520000,4.520000,0
1960-01-05,4.550000,4.550000,4.550000,4.550000,4.550000,0
1960-01-06,4.680000,4.680000,4.680000,4.680000,4.680000,0
1960-01-07,4.630000,4.630000,4.630000,4.630000,4.630000,0
1960-01-08,4.590000,4.590000,4.590000,4.590000,4.590000,0
1960-01-10,null,null,null,null,null,null
1960-01-11,4.540000,4.540000,4.540000,4.540000,4.540000,0
1960-01-12,4.540000,4.540000,4.540000,4.540000,4.540000,0
1960-01-13,4.560000,4.560000,4.560000,4.560000,4.560000,0
1960-01-14,4.510000,4.510000,4.510000,4.510000,4.510000,0
1960-01-15,4.490000,4.490000,4.490000,4.490000,4.490000,0
1960-01-17,null,null,null,null,null,null
1960-01-18,4.370000,4.370000,4.370000,4.370000,4.370000,0
1960-01-19,4.310000,4.310000,4.310000,4.310000,4.310000,0
1960-01-20,4.300000,4.300000,4.300000,4.300000,4.300000,0
1960-01-21,4.270000,4.270000,4.270000,4.270000,4.270000,0
1960-01-22,4.120000,4.120000,4.120000,4.120000,4.120000,0
1960-01-24,null,null,null,null,null,null
1960-01-25,4.120000,4.120000,4.120000,4.120000,4.120000,0
1960-01-26,4.040000,4.040000,4.040000,4.040000,4.040000,0
1960-01-27,3.990000,3.990000,3.990000,3.990000,3.990000,0
1960-01-28,3.920000,3.920000,3.920000,3.920000,3.920000,0
1960-01-29,3.990000,3.990000,3.990000,3.990000,3.990000,0
1960-01-31,null,null,null,null,null,null
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 15 Oct 2020 19:56:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Skipping-Invalid-Lines/m-p/691952#M210683</guid>
      <dc:creator>CurtisMackWSIPP</dc:creator>
      <dc:date>2020-10-15T19:56:53Z</dc:date>
    </item>
    <item>
      <title>Re: Skipping Invalid Lines</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Skipping-Invalid-Lines/m-p/691954#M210684</link>
      <description>&lt;P&gt;Subsetting first was the exact answer. Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Oct 2020 20:06:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Skipping-Invalid-Lines/m-p/691954#M210684</guid>
      <dc:creator>Junyong</dc:creator>
      <dc:date>2020-10-15T20:06:21Z</dc:date>
    </item>
    <item>
      <title>Re: Skipping Invalid Lines</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Skipping-Invalid-Lines/m-p/691956#M210685</link>
      <description>&lt;P&gt;It seems this will be useful for R CSVs, which put NAs for missings. Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Oct 2020 20:08:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Skipping-Invalid-Lines/m-p/691956#M210685</guid>
      <dc:creator>Junyong</dc:creator>
      <dc:date>2020-10-15T20:08:20Z</dc:date>
    </item>
    <item>
      <title>Re: Skipping Invalid Lines</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Skipping-Invalid-Lines/m-p/691964#M210690</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
  invalue myfmt "null" = .
                default = 10.5;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Did you really mean to set the value to 10.5 when the value is the string 'default'?&lt;/P&gt;
&lt;P&gt;If not then what did you think that second line meant?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Oct 2020 21:03:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Skipping-Invalid-Lines/m-p/691964#M210690</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-10-15T21:03:42Z</dc:date>
    </item>
    <item>
      <title>Re: Skipping Invalid Lines</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Skipping-Invalid-Lines/m-p/691965#M210691</link>
      <description>&lt;P&gt;Keep in mind that that solution will drop the record if any of the values are null, not just the "adj" variable.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Oct 2020 21:03:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Skipping-Invalid-Lines/m-p/691965#M210691</guid>
      <dc:creator>CurtisMackWSIPP</dc:creator>
      <dc:date>2020-10-15T21:03:49Z</dc:date>
    </item>
    <item>
      <title>Re: Skipping Invalid Lines</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Skipping-Invalid-Lines/m-p/691966#M210692</link>
      <description>&lt;P&gt;Try it.&amp;nbsp; You are thinking of the "OTHER" statement.&amp;nbsp; "DEFAULT" says use this existing format of 10.5.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Oct 2020 21:05:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Skipping-Invalid-Lines/m-p/691966#M210692</guid>
      <dc:creator>CurtisMackWSIPP</dc:creator>
      <dc:date>2020-10-15T21:05:30Z</dc:date>
    </item>
    <item>
      <title>Re: Skipping Invalid Lines</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Skipping-Invalid-Lines/m-p/691996#M210710</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/339357"&gt;@CurtisMackWSIPP&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Try it.&amp;nbsp; You are thinking of the "OTHER" statement.&amp;nbsp; "DEFAULT" says use this existing format of 10.5.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;There is no reason to use a different informat than what SAS normally uses to read numbers.&amp;nbsp; But if you did want to specify the use of an existing informat you need to enclose it square brackets.&amp;nbsp; But you wouldn't want to use an informat like 10.5 because that imposes an implied decimal point before the last 5 digits for this problem.&amp;nbsp; So any integer values would be divided by 10**5.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Oct 2020 23:54:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Skipping-Invalid-Lines/m-p/691996#M210710</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-10-15T23:54:25Z</dc:date>
    </item>
  </channel>
</rss>

