<?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: Skipped Observations During INFILE in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Skipped-Observations-During-INFILE/m-p/606819#M176280</link>
    <description>&lt;P&gt;&lt;STRONG&gt;Changing the variable name makes the first line shorter.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;You have not included the TRUNCOVER (or the older less useful MISSOVER) option on the INFILE statement, so when you read past the end of a line SAS will move to the next line to find a value for the variable.&amp;nbsp; SAS will tell you when it does this in the notes at the end of the data step.&amp;nbsp; You can also compare the number of lines read with the number of observations created.&lt;/P&gt;</description>
    <pubDate>Sun, 24 Nov 2019 15:40:10 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2019-11-24T15:40:10Z</dc:date>
    <item>
      <title>Skipped Observations During INFILE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Skipped-Observations-During-INFILE/m-p/606739#M176240</link>
      <description>&lt;P&gt;The following code downloads a time-series CSV from FRED and reads it.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename PCEND "%sysfunc(getoption(work))\PCEND.csv";
proc http method="get" out=PCEND url="https://fred.stlouisfed.org/graph/fredgraph.csv?id=PCEND";
run;
data PCEND;
infile PCEND;
input TIME yymmdd10. +1 PCEND;
TIME=put(TIME,yymmddn8.)+0;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The downloaded CSV has the following contents inside.&lt;/P&gt;&lt;PRE&gt;DATE,PCEND
1959-01-01,125.1
1959-02-01,125.4
1959-03-01,127.7
1959-04-01,125.6
1959-05-01,128.0
1959-06-01,127.9
1959-07-01,127.3
1959-08-01,127.9
1959-09-01,129.4
1959-10-01,129.8
1959-11-01,129.0
1959-12-01,129.7&lt;/PRE&gt;&lt;P&gt;Unfortunately, the resulting SAS data set displays missing values in the first row and starts from February in the second row. &lt;U&gt;I tried this code to read another variable (PCES) and there was no problem.&lt;/U&gt; What did I wrong here? Though FIRSTOBS=2 corrects this issue, I want to avoid FIRSTOBS as some files start from the third row. Thanks for your help.&lt;/P&gt;</description>
      <pubDate>Sun, 24 Nov 2019 04:07:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Skipped-Observations-During-INFILE/m-p/606739#M176240</guid>
      <dc:creator>Junyong</dc:creator>
      <dc:date>2019-11-24T04:07:48Z</dc:date>
    </item>
    <item>
      <title>Re: Skipped Observations During INFILE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Skipped-Observations-During-INFILE/m-p/606741#M176241</link>
      <description>&lt;P&gt;If you don't use FIRSTOBS=2, then SAS tries to read the first row which contains the string DATE,PCEND and it can't interpret this with informat &lt;FONT face="courier new,courier"&gt;yymmdd10.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How will you know which files have data starting in row 3 and which files have data starting in row 2? You could read the entire line as a text string, and if it finds an actual date in columns 1-10, convert that to a numeric SAS date using informat &lt;FONT face="courier new,courier"&gt;yymmdd10.&lt;/FONT&gt; But it would be a superior solution, in my opinion, to standardize the format of the files so they all have data beginning in row 2.&lt;/P&gt;</description>
      <pubDate>Sun, 24 Nov 2019 00:25:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Skipped-Observations-During-INFILE/m-p/606741#M176241</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-11-24T00:25:56Z</dc:date>
    </item>
    <item>
      <title>Re: Skipped Observations During INFILE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Skipped-Observations-During-INFILE/m-p/606742#M176242</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/173881"&gt;@Junyong&lt;/a&gt;&amp;nbsp; A simple question to consider.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Did it skip or the informat yymmdd10 used to read &lt;EM&gt;&lt;STRONG&gt;non-standard&lt;/STRONG&gt;&lt;/EM&gt; data and convert into number failed with log notes invalid data? This is obvious as the informat while appropriate for reading non-standard char dates would not be appropriate for standard char data that's in record 1.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The same rules apply when you are trying to read a standard char value as a numeric variable PCEND.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So in a nutshell the first record and the remaining records are different types and are not compatible for the instructions supplied in the INPUT statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope this helps&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 24 Nov 2019 00:28:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Skipped-Observations-During-INFILE/m-p/606742#M176242</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-11-24T00:28:27Z</dc:date>
    </item>
    <item>
      <title>Re: Skipped Observations During INFILE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Skipped-Observations-During-INFILE/m-p/606751#M176243</link>
      <description>&lt;P&gt;Also this statement doesn't make a lot of sense:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;TIME=put(TIME,yymmddn8.)+0;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It looks like you are trying to add 0 to a date character string then assign it to time variable. I bet you are getting notes in your SAS log about conversion from character to numeric. What do you actually want to do here?&lt;/P&gt;</description>
      <pubDate>Sun, 24 Nov 2019 01:07:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Skipped-Observations-During-INFILE/m-p/606751#M176243</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2019-11-24T01:07:55Z</dc:date>
    </item>
    <item>
      <title>Re: Skipped Observations During INFILE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Skipped-Observations-During-INFILE/m-p/606753#M176244</link>
      <description>&lt;P&gt;There is nothing wrong with your INFILE statement. You just need to make your use of INPUT smarter.&lt;/P&gt;
&lt;P&gt;Sounds like you just want to ignore lines that don't have a value date in the first field.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data PCEND;
  infile PCEND dsd truncover ;
  input TIME : ?? yymmdd10. @ ;
  if missing(time) then delete ;
  input PCEND ;
  format TIME yymmdd10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;PS Why would you name a variable that contains date values time?&amp;nbsp; That is just going to confuse somebody.&lt;/P&gt;</description>
      <pubDate>Sun, 24 Nov 2019 01:30:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Skipped-Observations-During-INFILE/m-p/606753#M176244</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-11-24T01:30:32Z</dc:date>
    </item>
    <item>
      <title>Re: Skipped Observations During INFILE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Skipped-Observations-During-INFILE/m-p/606756#M176245</link>
      <description>&lt;P&gt;I understand that SAS cannot read the strings. However, shouldn't this be the same for other data too? The following code just alters PCEND by PCES.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename PCES "%sysfunc(getoption(work))\PCES.csv";
proc http method="get" out=PCES url="https://fred.stlouisfed.org/graph/fredgraph.csv?id=PCES";
run;
data PCES;
infile PCES;
input TIME yymmdd10. +1 PCES;
TIME=put(TIME,yymmddn8.)+0;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This CSV file has the same structure.&lt;/P&gt;&lt;PRE&gt;DATE,PCES
1959-01-01,138.7
1959-02-01,140.0
1959-03-01,140.5
1959-04-01,141.5
1959-05-01,142.8
1959-06-01,144.3
1959-07-01,145.1
1959-08-01,146.1
1959-09-01,147.4
1959-10-01,148.3
1959-11-01,149.2
1959-12-01,150.4&lt;/PRE&gt;&lt;P&gt;So if the previous problem is the strings in the first line, then the first line here shouldn't be recognized. Unlike the previous case, however, SAS correctly reads all the file from January even without the FIRSTOBS adjustment. What would be the difference here then?&lt;/P&gt;</description>
      <pubDate>Sun, 24 Nov 2019 03:54:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Skipped-Observations-During-INFILE/m-p/606756#M176245</guid>
      <dc:creator>Junyong</dc:creator>
      <dc:date>2019-11-24T03:54:00Z</dc:date>
    </item>
    <item>
      <title>Re: Skipped Observations During INFILE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Skipped-Observations-During-INFILE/m-p/606757#M176246</link>
      <description>&lt;P&gt;Thanks, but I attached some additional findings right above—when I just change the variable from PCEND to PCES, SAS just reads all the data in a correct way. Both data have an identical structure starting from the second. Then why are the results different here?&lt;/P&gt;</description>
      <pubDate>Sun, 24 Nov 2019 03:34:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Skipped-Observations-During-INFILE/m-p/606757#M176246</guid>
      <dc:creator>Junyong</dc:creator>
      <dc:date>2019-11-24T03:34:48Z</dc:date>
    </item>
    <item>
      <title>Re: Skipped Observations During INFILE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Skipped-Observations-During-INFILE/m-p/606758#M176247</link>
      <description>&lt;P&gt;No note—this line changes the numeric value -365 to 19590101.&lt;/P&gt;</description>
      <pubDate>Sun, 24 Nov 2019 03:39:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Skipped-Observations-During-INFILE/m-p/606758#M176247</guid>
      <dc:creator>Junyong</dc:creator>
      <dc:date>2019-11-24T03:39:42Z</dc:date>
    </item>
    <item>
      <title>Re: Skipped Observations During INFILE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Skipped-Observations-During-INFILE/m-p/606763#M176249</link>
      <description>&lt;P&gt;If the INFILE is the troublemaker, then shouldn't it be the same for other cases? But this code produces no problem when it just reads PCES rather than PECND as follows.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename PCES "%sysfunc(getoption(work))\PCES.csv";
proc http method="get" out=PCES url="https://fred.stlouisfed.org/graph/fredgraph.csv?id=PCES";
run;
data PCES;
infile PCES;
input TIME yymmdd10. +1 PCES;
TIME=put(TIME,yymmddn8.)+0;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Both PCES and PCEND are structurally identical as follows.&lt;/P&gt;&lt;PRE&gt;DATE,PCES
1959-01-01,138.7
1959-02-01,140.0
1959-03-01,140.5
1959-04-01,141.5
1959-05-01,142.8
1959-06-01,144.3
1959-07-01,145.1
1959-08-01,146.1
1959-09-01,147.4
1959-10-01,148.3
1959-11-01,149.2
1959-12-01,150.4&lt;/PRE&gt;&lt;P&gt;The left and right are PCEND and PCES, respectively. SAS doesn't read the January in PCEND, but does read in PCES.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1.png" style="width: 200px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/34204iA0E2E31F790927BB/image-size/small?v=v2&amp;amp;px=200" role="button" title="1.png" alt="1.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2.png" style="width: 200px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/34205i509E5C67C58CB5A8/image-size/small?v=v2&amp;amp;px=200" role="button" title="2.png" alt="2.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Why are the results different?&lt;/P&gt;&lt;P&gt;By the way, some FRED data are uneven—UMCSENT, for example, is less frequent than monthly before 1978, but becomes monthly in 1978. Also, date information in FRED such as 1950-01-01 actually means 1950-01-31 sometimes. So I rather used TIME here.&lt;/P&gt;</description>
      <pubDate>Sun, 24 Nov 2019 04:05:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Skipped-Observations-During-INFILE/m-p/606763#M176249</guid>
      <dc:creator>Junyong</dc:creator>
      <dc:date>2019-11-24T04:05:00Z</dc:date>
    </item>
    <item>
      <title>Re: Skipped Observations During INFILE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Skipped-Observations-During-INFILE/m-p/606766#M176250</link>
      <description>&lt;P&gt;Why do you not want to use SAS dates? You are converting a SAS date (-365 is a SAS date without a SAS date format applied to it) to just a plain number that represents a date.&lt;/P&gt;</description>
      <pubDate>Sun, 24 Nov 2019 04:58:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Skipped-Observations-During-INFILE/m-p/606766#M176250</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2019-11-24T04:58:17Z</dc:date>
    </item>
    <item>
      <title>Re: Skipped Observations During INFILE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Skipped-Observations-During-INFILE/m-p/606767#M176251</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/173881"&gt;@Junyong&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;If the INFILE is the troublemaker, then shouldn't it be the same for other cases? But this code produces no problem when it just reads PCES rather than PECND as follows.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename PCES "%sysfunc(getoption(work))\PCES.csv";
proc http method="get" out=PCES url="https://fred.stlouisfed.org/graph/fredgraph.csv?id=PCES";
run;
data PCES;
infile PCES;
input TIME yymmdd10. +1 PCES;
TIME=put(TIME,yymmddn8.)+0;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;By the way, some FRED data are uneven—UMCSENT, for example, is less frequent than monthly before 1978, but becomes monthly in 1978. Also, date information in FRED such as 1950-01-01 actually means 1950-01-31 sometimes. So I rather used TIME here.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I too strongly suggest you don't use the variable TIME to contain a data value, even when that date sometimes uses the&amp;nbsp; 1st of a month, or the end of a month to identify&amp;nbsp; a monthly report.&amp;nbsp; I suggest you use DATE, but add the following statement&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATE = intnx('month',DATE,0,'END');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;which will adjust any date to the last day of the month.&lt;/P&gt;</description>
      <pubDate>Sun, 24 Nov 2019 05:23:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Skipped-Observations-During-INFILE/m-p/606767#M176251</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2019-11-24T05:23:44Z</dc:date>
    </item>
    <item>
      <title>Re: Skipped Observations During INFILE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Skipped-Observations-During-INFILE/m-p/606813#M176278</link>
      <description>&lt;P&gt;I know I can use&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;format TIME yymmddn8.;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;but I am using this unusual way due to a different reason (senior coworker) for this time only.&lt;/P&gt;</description>
      <pubDate>Sun, 24 Nov 2019 13:33:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Skipped-Observations-During-INFILE/m-p/606813#M176278</guid>
      <dc:creator>Junyong</dc:creator>
      <dc:date>2019-11-24T13:33:48Z</dc:date>
    </item>
    <item>
      <title>Re: Skipped Observations During INFILE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Skipped-Observations-During-INFILE/m-p/606815#M176279</link>
      <description>&lt;P&gt;In other cases, I use&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;format TIME yymmddn8.;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;to format the observations or&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;TIME=intnx("month",TIME,0,"e");&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;to transform 1900-01-01 to 1900-01-31. I am using this unusual way due to a different reason only for this time. Thanks.&lt;/P&gt;</description>
      <pubDate>Sun, 24 Nov 2019 13:50:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Skipped-Observations-During-INFILE/m-p/606815#M176279</guid>
      <dc:creator>Junyong</dc:creator>
      <dc:date>2019-11-24T13:50:53Z</dc:date>
    </item>
    <item>
      <title>Re: Skipped Observations During INFILE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Skipped-Observations-During-INFILE/m-p/606819#M176280</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Changing the variable name makes the first line shorter.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;You have not included the TRUNCOVER (or the older less useful MISSOVER) option on the INFILE statement, so when you read past the end of a line SAS will move to the next line to find a value for the variable.&amp;nbsp; SAS will tell you when it does this in the notes at the end of the data step.&amp;nbsp; You can also compare the number of lines read with the number of observations created.&lt;/P&gt;</description>
      <pubDate>Sun, 24 Nov 2019 15:40:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Skipped-Observations-During-INFILE/m-p/606819#M176280</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-11-24T15:40:10Z</dc:date>
    </item>
    <item>
      <title>Re: Skipped Observations During INFILE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Skipped-Observations-During-INFILE/m-p/606820#M176281</link>
      <description>&lt;P&gt;If you want to convert a date value into a number in YY,YYM,MDD format you should be clearer in your code to avoid confusion.&amp;nbsp; Instead of adding zero to a character string, use the INPUT() function to convert the string into a number.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;time=input(put(time.yymmddn8.),8.);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 24 Nov 2019 15:43:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Skipped-Observations-During-INFILE/m-p/606820#M176281</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-11-24T15:43:34Z</dc:date>
    </item>
    <item>
      <title>Re: Skipped Observations During INFILE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Skipped-Observations-During-INFILE/m-p/606931#M176338</link>
      <description>&lt;P&gt;If all your files are the same csv format (comma-delimited), I would use that in the infile statement, e.g.:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data PCEND;
  infile PCEND dsd delimiter=',' truncover;
  input TIME ?? yymmdd10. PCEND ??;
  if not misssing(TIME);
  TIME=put(TIME,yymmddn8.)+0;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I put the question marks in the input statement to avoid warnings in the log when reading the first one or two lines with headers.&lt;/P&gt;
&lt;P&gt;the "if not missing(TIME)" line removes the header lines from the output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Nov 2019 11:46:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Skipped-Observations-During-INFILE/m-p/606931#M176338</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2019-11-25T11:46:15Z</dc:date>
    </item>
  </channel>
</rss>

