<?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 data from datalines in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-datalines/m-p/941705#M369420</link>
    <description>&lt;P&gt;If you never having missing values of X just read until you find a missing value.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data grid;
  infile datalines truncover ;
  input area $ @ ;
  do rep=1 by 1 until(x=.);
    input x y @ ;
    if (rep=1) or (x ne .) then output;
  end;
datalines;
E 0 150  35 155  50 550
D 0 100  25 100  50 125  80 215  125 550
C 0 60   30 60   50 80   70 110  260 550
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you might have missing values then just read until you read past the end of the line.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data grid;
  infile datalines column=cc length=ll truncover ;
  input area $ @ ;
  do rep=1 by 1 until(cc&amp;gt;ll);
    input x y @ ;
    if (rep=1) or n(x,y) then output;
  end;
datalines;
E 0 150  35 155  50 550
D 0 100  25 100  50 125  80 215  125 550
C 0 60   30 60   50 80   70 110  260 550
;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 29 Aug 2024 12:55:53 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2024-08-29T12:55:53Z</dc:date>
    <item>
      <title>Reading data from datalines</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-datalines/m-p/941632#M369414</link>
      <description>&lt;P&gt;I want to read a series of coordinate into SAS dataset. There are three variables: AREA, X and Y. AREA is a character variable.&lt;/P&gt;
&lt;P&gt;When there is only one value of AREA and coresponding (X,Y) coordinates, I can use the program:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data grid;
  retain area;
  if _n_=1 then input area :$1. @;
  input x y @@;
  datalines;
E 0 150  35 155  50 550
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The result what I want:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;AREA&amp;nbsp; &amp;nbsp; X&amp;nbsp; &amp;nbsp; Y&lt;/P&gt;
&lt;P&gt;The 1st Row:&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; E&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&amp;nbsp; &amp;nbsp; 150&lt;/P&gt;
&lt;P&gt;The 2nd Row:&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; E&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 35&amp;nbsp; &amp;nbsp;155&lt;/P&gt;
&lt;P&gt;The 3rd Row:&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;E&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 50&amp;nbsp; &amp;nbsp;550&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But I cann't handle condition with multiple level of AREA:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data grid;
  retain area;
  if _n_=1 then input area :$1. @;
  input x y @@;
  datalines;
E 0 150  35 155  50 550
D 0 100  25 100  50 125  80 215  125 550
C 0 60   30 60   50 80   70 110  260 550
;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This program failed.&lt;/P&gt;
&lt;P&gt;Another difficulty is there maybe 3, 4 or 5 coordinates for each level of AREA.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please help, Rearrange datalines is allowed but I don't want it occupy too much row, because I am putting it into presentation.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Aug 2024 07:25:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-datalines/m-p/941632#M369414</guid>
      <dc:creator>whymath</dc:creator>
      <dc:date>2024-08-29T07:25:38Z</dc:date>
    </item>
    <item>
      <title>Re: Reading data from datalines</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-datalines/m-p/941645#M369415</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1724917379486.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/99722i27E642D9F8614407/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1724917379486.png" alt="Ksharp_0-1724917379486.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Aug 2024 07:43:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-datalines/m-p/941645#M369415</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-08-29T07:43:17Z</dc:date>
    </item>
    <item>
      <title>Re: Reading data from datalines</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-datalines/m-p/941705#M369420</link>
      <description>&lt;P&gt;If you never having missing values of X just read until you find a missing value.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data grid;
  infile datalines truncover ;
  input area $ @ ;
  do rep=1 by 1 until(x=.);
    input x y @ ;
    if (rep=1) or (x ne .) then output;
  end;
datalines;
E 0 150  35 155  50 550
D 0 100  25 100  50 125  80 215  125 550
C 0 60   30 60   50 80   70 110  260 550
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you might have missing values then just read until you read past the end of the line.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data grid;
  infile datalines column=cc length=ll truncover ;
  input area $ @ ;
  do rep=1 by 1 until(cc&amp;gt;ll);
    input x y @ ;
    if (rep=1) or n(x,y) then output;
  end;
datalines;
E 0 150  35 155  50 550
D 0 100  25 100  50 125  80 215  125 550
C 0 60   30 60   50 80   70 110  260 550
;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 29 Aug 2024 12:55:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-datalines/m-p/941705#M369420</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-08-29T12:55:53Z</dc:date>
    </item>
  </channel>
</rss>

