<?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: Reading raw data from an external files in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Reading-raw-data-from-an-external-files/m-p/329320#M73658</link>
    <description>&lt;P&gt;Sorry.. the log i pasted that was for 3rd syntax. while running second there is no error but data is coming incorrect. see attached screenshot.&lt;/P&gt;</description>
    <pubDate>Thu, 02 Feb 2017 08:33:26 GMT</pubDate>
    <dc:creator>komalbatra</dc:creator>
    <dc:date>2017-02-02T08:33:26Z</dc:date>
    <item>
      <title>Reading raw data from an external files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-raw-data-from-an-external-files/m-p/329296#M73651</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a&amp;nbsp;space delimeted data from external file where 1 record has a missing value but there is no '.' sign there only space is given there So when i am trying using dlm option=' ' or dsd option or both it doesn't provide me correct data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;here is the data:&lt;/P&gt;&lt;P&gt;M 50 68 155&lt;BR /&gt;F &amp;nbsp; 60 101&lt;BR /&gt;M 65 72 220&lt;BR /&gt;F 35 65 133&lt;BR /&gt;M 15 71 166&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;&lt;P&gt;Here is the code:&lt;/P&gt;&lt;P&gt;Age(2nd column) is missing in the 2nd row of data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data demo;&lt;BR /&gt;infile "demo.txt" dlm=' ';&lt;BR /&gt;input gender $ age height weight;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data demo;&lt;BR /&gt;infile "demo.txt" dlm=' ' dsd;&lt;BR /&gt;input gender $ age height weight;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;data demo;&lt;BR /&gt;infile "demo.txt" dsd;&lt;BR /&gt;input gender $ age height weight;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Feb 2017 05:35:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-raw-data-from-an-external-files/m-p/329296#M73651</guid>
      <dc:creator>komalbatra</dc:creator>
      <dc:date>2017-02-02T05:35:38Z</dc:date>
    </item>
    <item>
      <title>Re: Reading raw data from an external files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-raw-data-from-an-external-files/m-p/329307#M73655</link>
      <description>&lt;P&gt;I would have expected the second to work.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you post the log from that run?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Feb 2017 07:02:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-raw-data-from-an-external-files/m-p/329307#M73655</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-02-02T07:02:42Z</dc:date>
    </item>
    <item>
      <title>Re: Reading raw data from an external files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-raw-data-from-an-external-files/m-p/329317#M73657</link>
      <description>&lt;P&gt;here is the log:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;NOTE: The infile "demo.txt" is:&lt;BR /&gt;File Name=C:\Users\Acer\Desktop\demo.txt,&lt;BR /&gt;RECFM=V,LRECL=256&lt;/P&gt;&lt;P&gt;NOTE: Invalid data for age in line 2 1-10.&lt;BR /&gt;NOTE: Invalid data for height in line 3 1-11.&lt;BR /&gt;NOTE: Invalid data for weight in line 4 1-11.&lt;BR /&gt;RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9--&lt;BR /&gt;4 F 35 65 133 11&lt;BR /&gt;NOTE: Invalid data errors for file '"demo.txt"' occurred outside the printed range.&lt;BR /&gt;NOTE: Increase available buffer lines with the INFILE n= option.&lt;BR /&gt;gender=M 50 68 age=. height=. weight=. _ERROR_=1 _N_=1&lt;BR /&gt;NOTE: LOST CARD.&lt;BR /&gt;gender=M 15 71 age=. height=. weight=. _ERROR_=1 _N_=2&lt;BR /&gt;NOTE: 5 records were read from the infile "demo.txt".&lt;BR /&gt;The minimum record length was 10.&lt;BR /&gt;The maximum record length was 11.&lt;BR /&gt;NOTE: SAS went to a new line when INPUT statement reached past the end of a line.&lt;BR /&gt;NOTE: The data set WORK.DEMO has 1 observations and 4 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.01 seconds&lt;BR /&gt;cpu time 0.01 seconds&lt;/P&gt;</description>
      <pubDate>Thu, 02 Feb 2017 08:26:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-raw-data-from-an-external-files/m-p/329317#M73657</guid>
      <dc:creator>komalbatra</dc:creator>
      <dc:date>2017-02-02T08:26:37Z</dc:date>
    </item>
    <item>
      <title>Re: Reading raw data from an external files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-raw-data-from-an-external-files/m-p/329320#M73658</link>
      <description>&lt;P&gt;Sorry.. the log i pasted that was for 3rd syntax. while running second there is no error but data is coming incorrect. see attached screenshot.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Feb 2017 08:33:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-raw-data-from-an-external-files/m-p/329320#M73658</guid>
      <dc:creator>komalbatra</dc:creator>
      <dc:date>2017-02-02T08:33:26Z</dc:date>
    </item>
    <item>
      <title>Re: Reading raw data from an external files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-raw-data-from-an-external-files/m-p/329321#M73659</link>
      <description>i think there is 3 spaces between next code that was reason for 2 missing value coming in the output .if i try with 2 spaces its coming fine. Thank you.</description>
      <pubDate>Thu, 02 Feb 2017 08:37:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-raw-data-from-an-external-files/m-p/329321#M73659</guid>
      <dc:creator>komalbatra</dc:creator>
      <dc:date>2017-02-02T08:37:44Z</dc:date>
    </item>
    <item>
      <title>Re: Reading raw data from an external files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-raw-data-from-an-external-files/m-p/329443#M73707</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Related post

If you are using the 'old text editor' the command 'cuth' will change mutiple blanks to one blank.

/* T000800 Old text editor macro to compress mutiple blanks to one blank in editor (like compbl)


Old text editor macro to compress mutiple blanks to one blank in editor (like compbl)

HAVE
====

INPUT ID        DATE              ABREV       COUNT        REGION    SALES
297945203711 2009.08.31             MO          1            KS    60
297945203711 2009.08.31             MO          2            KU    50
297945303711 2009.08.31             SS          1            MA    60
297945303711 2009.08.31             SS          1            KS    60
297945403711 2009.08.31             JO          1            HB    NA

WANT
====

INPUT ID DATE ABREV COUNT REGION SALES
297945203711 2009.08.31 MO 1 KS 60
297945203711 2009.08.31 MO 2 KU 50
297945303711 2009.08.31 SS 1 MA 60
297945303711 2009.08.31 SS 1 KS 60
297945403711 2009.08.31 JO 1 HB NA


WORKING CODE (may work in enhanced editor?)
===========================================

  %do i=1 %to 20;
    c '  ' ' ' all;
  %end;

DETAILS
=======

Highlight the code where you want to change mutiple blanks to one blank
Type cuth on the command line

ie
Command ==&amp;gt; cuth

00001 INPUT ID        DATE              ABREV       COUNT        REGION    SALES
00002 297945203711 2009.08.31             MO          1            KS    60
00003 297945203711 2009.08.31             MO          2            KU    50
00004 297945303711 2009.08.31             SS          1            MA    60
00005 297945303711 2009.08.31             SS          1            KS    60
00006 297945403711 2009.08.31             JO          1            HB    NA


FULL SOLUTION
=============

PUT THE MACRO BELOW IN YOUR AUTOCALL FOLDER.
Make sure CMDMAC is turned in.
options cmdmac;

Highlight the lines you want to compress and type 'cuth' on the commandline.

%macro cuth/cmd;
  %do i=1 %to 20;
    c '  ' ' ' all;
  %end;
%mend cutout;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 02 Feb 2017 14:43:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-raw-data-from-an-external-files/m-p/329443#M73707</guid>
      <dc:creator>rogerjdeangelis</dc:creator>
      <dc:date>2017-02-02T14:43:59Z</dc:date>
    </item>
    <item>
      <title>Re: Reading raw data from an external files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-raw-data-from-an-external-files/m-p/329492#M73722</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/124879"&gt;@komalbatra&lt;/a&gt; wrote:&lt;BR /&gt;i think there is 3 spaces between next code that was reason for 2 missing value coming in the output .if i try with 2 spaces its coming fine. Thank you.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;DSD treats 2 consecutive delimiters as one missing, when you have 3 as the example data shows then the result is 2 missing variables.&lt;/P&gt;
&lt;P&gt;The blanks at column 2 and 3 are the first pair and then at columns 3 and 4 are a second pair.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If possible determine why the data source is placing a space for a missing value and see if it may be corrected there, especially if this is going to be a process repeated on files going forward such as every week or&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the problem is regular enough this edit to the input line before inputting the variables may fix the problem:&lt;/P&gt;
&lt;PRE&gt;data demo;
infile datalines dlm=' ' dsd;
input @;
_infile_= tranwrd(_infile_,'   ','  ');
input gender $   age  height weight;
datalines;
M 50 68 155
F   60 101
M 65 72 220
F 35 65 133
M 15 71 166
;
run;
&lt;/PRE&gt;</description>
      <pubDate>Thu, 02 Feb 2017 16:10:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-raw-data-from-an-external-files/m-p/329492#M73722</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-02-02T16:10:13Z</dc:date>
    </item>
  </channel>
</rss>

