<?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: Trouble Entering Data, Text String With Spaces in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Trouble-Entering-Data-Text-String-With-Spaces/m-p/648565#M194312</link>
    <description>&lt;P&gt;If it doesn't make sense to you, here's the documentation.&amp;nbsp; That might help it make sense.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/?docsetId=lestmtsref&amp;amp;docsetTarget=n0lrz3gb7m9e4rn137op544ddg0v.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en#n1dyx4r7yqsmuun1mk3cbw7ih06w"&gt;https://documentation.sas.com/?docsetId=lestmtsref&amp;amp;docsetTarget=n0lrz3gb7m9e4rn137op544ddg0v.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en#n1dyx4r7yqsmuun1mk3cbw7ih06w&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 18 May 2020 14:32:01 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2020-05-18T14:32:01Z</dc:date>
    <item>
      <title>Trouble Entering Data, Text String With Spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trouble-Entering-Data-Text-String-With-Spaces/m-p/648501#M194280</link>
      <description>&lt;P&gt;Part of dataset, as a regular text file:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;i_20304   &amp;gt;= 1.64214 AND &amp;lt; 4.42166   105    0.7048
i_20304   &amp;gt;= 1.64214 AND &amp;lt; 4.81874    17    1.0000
i_20304   &amp;gt;= 1.64214 AND &amp;lt; 4.81874   179    0.5475
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Code attempted&amp;nbsp; to create SAS dataset:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sas_1.Variable_Values;
infile "C:\0_SAS_3\Variable Values2.txt" ;
input
Indicator $ Range $ Number Pct_Yes ;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The issue is in getting the &lt;STRONG&gt;second variable&lt;/STRONG&gt; into SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&amp;gt;= 1.64214 AND &amp;lt; 4.42166&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried putting that variable in quotes.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;"&amp;gt;= 1.64214 AND &amp;lt; 4.42166"&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But SAS then split when it ran into the first space character.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any guidance greatly appreciated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Nicholas Kormanik&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 May 2020 09:05:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trouble-Entering-Data-Text-String-With-Spaces/m-p/648501#M194280</guid>
      <dc:creator>NKormanik</dc:creator>
      <dc:date>2020-05-18T09:05:53Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble Entering Data, Text String With Spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trouble-Entering-Data-Text-String-With-Spaces/m-p/648504#M194281</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/22691"&gt;@NKormanik&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe you could try to use the DSD option in the INFILE statement, as well as the DLM option to specify the delimiter (space (" ")? tabulation ("09"x)?).&lt;/P&gt;
&lt;P&gt;The DSD option&amp;nbsp;&lt;SPAN&gt;specifies that when data values are enclosed in quotation marks (as you did), delimiters within the value are treated as character data.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Hope this helps.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Best,&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 18 May 2020 09:59:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trouble-Entering-Data-Text-String-With-Spaces/m-p/648504#M194281</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-05-18T09:59:15Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble Entering Data, Text String With Spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trouble-Entering-Data-Text-String-With-Spaces/m-p/648507#M194283</link>
      <description>It looks like your data contains multiple blanks between fields.  Take advantage of that:&lt;BR /&gt;&lt;BR /&gt;input indicator $ range $ &amp;amp;  number pct_yes;&lt;BR /&gt;&lt;BR /&gt;The &amp;amp; tells SAS to look for two consecutive blanks to mark the end of a variable.</description>
      <pubDate>Mon, 18 May 2020 10:16:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trouble-Entering-Data-Text-String-With-Spaces/m-p/648507#M194283</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2020-05-18T10:16:03Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble Entering Data, Text String With Spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trouble-Entering-Data-Text-String-With-Spaces/m-p/648522#M194291</link>
      <description>&lt;P&gt;The above suggestions just do not make sense to me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The 'delimiters' in a standard text file (actually output from a SAS job) are spaces.&amp;nbsp; Lots of spaces.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The output included what is shown in the original question.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to now get it (said output, or portion thereof) into a SAS database.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The question is how to get the following into the second variable:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token operator"&gt;&amp;gt;=&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1.64214&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="token keyword"&gt;AND&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;4.42166&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Everything I've tried seems to choke SAS.&amp;nbsp; How can I make this seemingly basic task more understandable to SAS?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS -- there are 2 million such lines to get in, some smaller, some larger.&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>Mon, 18 May 2020 11:20:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trouble-Entering-Data-Text-String-With-Spaces/m-p/648522#M194291</guid>
      <dc:creator>NKormanik</dc:creator>
      <dc:date>2020-05-18T11:20:53Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble Entering Data, Text String With Spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trouble-Entering-Data-Text-String-With-Spaces/m-p/648532#M194296</link>
      <description>&lt;P&gt;Your example makes it look like the data is in fixed columns.&lt;/P&gt;
&lt;PRE&gt;----+----1----+----2----+----3----+----4----+----5
i_20304   &amp;gt;= 1.64214 AND &amp;lt; 4.42166   105    0.7048
i_20304   &amp;gt;= 1.64214 AND &amp;lt; 4.81874    17    1.0000
i_20304   &amp;gt;= 1.64214 AND &amp;lt; 4.81874   179    0.5475
----+----1----+----2----+----3----+----4----+----5&lt;/PRE&gt;
&lt;P&gt;So tell SAS that in your INPUT statement.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;input Indicator $ 1-9 Range $ 11-35 Number Pct_Yes ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 May 2020 12:45:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trouble-Entering-Data-Text-String-With-Spaces/m-p/648532#M194296</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-05-18T12:45:34Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble Entering Data, Text String With Spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trouble-Entering-Data-Text-String-With-Spaces/m-p/648533#M194297</link>
      <description>&lt;P&gt;In case there are always all columns then you can use next code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  infile datalines;
  length indicator $7  range $25;
  input row $50.;
  row = compbl(row);
  indicator = scan(row,1);
  do i=2 to 5; range=catx(' ',range,scan(row,i)); end;
  number = scan(row,7,' ');
  pct = scan(row,8,' ');
  drop i row;
datalines;
i_20304   &amp;gt;= 1.64214 AND &amp;lt; 4.42166   105    0.7048
i_20304   &amp;gt;= 1.64214 AND &amp;lt; 4.81874    17    1.0000
i_20304   &amp;gt;= 1.64214 AND &amp;lt; 4.81874   179    0.5475
; run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 May 2020 12:53:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trouble-Entering-Data-Text-String-With-Spaces/m-p/648533#M194297</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2020-05-18T12:53:54Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble Entering Data, Text String With Spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trouble-Entering-Data-Text-String-With-Spaces/m-p/648565#M194312</link>
      <description>&lt;P&gt;If it doesn't make sense to you, here's the documentation.&amp;nbsp; That might help it make sense.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/?docsetId=lestmtsref&amp;amp;docsetTarget=n0lrz3gb7m9e4rn137op544ddg0v.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en#n1dyx4r7yqsmuun1mk3cbw7ih06w"&gt;https://documentation.sas.com/?docsetId=lestmtsref&amp;amp;docsetTarget=n0lrz3gb7m9e4rn137op544ddg0v.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en#n1dyx4r7yqsmuun1mk3cbw7ih06w&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 18 May 2020 14:32:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trouble-Entering-Data-Text-String-With-Spaces/m-p/648565#M194312</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2020-05-18T14:32:01Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble Entering Data, Text String With Spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trouble-Entering-Data-Text-String-With-Spaces/m-p/648613#M194334</link>
      <description>&lt;P&gt;When reading in text that is not in a fixed format, i prefer to use the automatic variable _infile_ and then I have more control with the wealth of string handling functions.&amp;nbsp; eg.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sasodde;
length infile_copy $1024;
infile ..... end=eof;
input ;
infile_copy=_infile_;

/* now use scan, substrn, and other string functions to parse infile_copy */


run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 May 2020 16:18:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trouble-Entering-Data-Text-String-With-Spaces/m-p/648613#M194334</guid>
      <dc:creator>DavePrinsloo</dc:creator>
      <dc:date>2020-05-18T16:18:30Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble Entering Data, Text String With Spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trouble-Entering-Data-Text-String-With-Spaces/m-p/648614#M194335</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/22691"&gt;@NKormanik&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;The above suggestions just do not make sense to me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The 'delimiters' in a standard text file (&lt;FONT color="#FF00FF"&gt;&lt;STRONG&gt;actually output from a SAS job&lt;/STRONG&gt;&lt;/FONT&gt;) are spaces.&amp;nbsp; Lots of spaces.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;May be it would be a good idea to share details of the SAS job creating that text. Generally creating output to read back in is poorer than using the options to create a data set directly. I know I have done such in SAS 5.18 and SAS 6 because there wasn't a good option for some things. But that is has changed a lot in the past 20+ years.&lt;/P&gt;
&lt;P&gt;Plus most of the SAS text output is fixed column, not space delimited. Space delimited would generally be ONE space not "many". Fixed column however often is generated by "padding" values with "many spaces" get the columns to align.&lt;/P&gt;</description>
      <pubDate>Mon, 18 May 2020 16:19:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trouble-Entering-Data-Text-String-With-Spaces/m-p/648614#M194335</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-05-18T16:19:01Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble Entering Data, Text String With Spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trouble-Entering-Data-Text-String-With-Spaces/m-p/648616#M194336</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Are you asking how to type the data into the text file in a way that will be easy for SAS to read?&amp;nbsp; &lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;If so then you should use fixed columns for the data or use a delimited file format.&amp;nbsp; IN the delimited format any value that contains the character you used for the delimiter should be quoted.&amp;nbsp; Any values with actual double quote characters should also be quoted and the existing quotes doubled up.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Or are you trying to read an existing text file?&amp;nbsp; &lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;If so then post a few more example lines, as the ones you posted are easy to read using fixed columns for each field.&lt;/P&gt;</description>
      <pubDate>Mon, 18 May 2020 16:25:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trouble-Entering-Data-Text-String-With-Spaces/m-p/648616#M194336</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-05-18T16:25:51Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble Entering Data, Text String With Spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trouble-Entering-Data-Text-String-With-Spaces/m-p/648734#M194391</link>
      <description>If one goes this route, will leading and trailing spaces be automatically deleted?&lt;BR /&gt;&lt;BR /&gt;Why 1-9 and 11-35 as opposed to 1-9 and 10-35?&lt;BR /&gt;&lt;BR /&gt;No need for specifying columns for Number and Pct_Yes?&lt;BR /&gt;</description>
      <pubDate>Tue, 19 May 2020 01:44:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trouble-Entering-Data-Text-String-With-Spaces/m-p/648734#M194391</guid>
      <dc:creator>NKormanik</dc:creator>
      <dc:date>2020-05-19T01:44:34Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble Entering Data, Text String With Spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trouble-Entering-Data-Text-String-With-Spaces/m-p/648735#M194392</link>
      <description>This is a response that I can understand.  I so appreciate that.&lt;BR /&gt;&lt;BR /&gt;My hunch is, fixed columns is probably the way to go.  So I need to read up on fixed columns.&lt;BR /&gt;&lt;BR /&gt;Thanks!&lt;BR /&gt;</description>
      <pubDate>Tue, 19 May 2020 01:50:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trouble-Entering-Data-Text-String-With-Spaces/m-p/648735#M194392</guid>
      <dc:creator>NKormanik</dc:creator>
      <dc:date>2020-05-19T01:50:19Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble Entering Data, Text String With Spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trouble-Entering-Data-Text-String-With-Spaces/m-p/648742#M194395</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/22691"&gt;@NKormanik&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;If one goes this route, will leading and trailing spaces be automatically deleted?&lt;BR /&gt;&lt;BR /&gt;Why 1-9 and 11-35 as opposed to 1-9 and 10-35?&lt;BR /&gt;&lt;BR /&gt;No need for specifying columns for Number and Pct_Yes?&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You will need to look at the file to decide whether fixed columns work. Make sure to look at the data using a fixed space font and not a proportional font.&amp;nbsp; I think that SAS will ignore leading spaces in a field, at least that is how it normally reads strings. If you want it to treat the leading spaces as significant you have to use the $CHAR informat.&lt;/P&gt;
&lt;P&gt;You should probably also figure out the columns for the other fields.&amp;nbsp; It doesn't matter for the example lines because none of the lines have only blanks in those fields and none of the fields actually abut directly on each other.&amp;nbsp; Without the column numbers it will revert to list mode input and hunt for the next non-blank text to read.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 May 2020 02:21:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trouble-Entering-Data-Text-String-With-Spaces/m-p/648742#M194395</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-05-19T02:21:21Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble Entering Data, Text String With Spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trouble-Entering-Data-Text-String-With-Spaces/m-p/648761#M194402</link>
      <description>An issue with fixed-column statement:  As one might imagine, if the total number of rows in the file exceeds 2 million, it's taxing to page down and examine every page to make sure each and every line is exactly lined up as expected.&lt;BR /&gt;</description>
      <pubDate>Tue, 19 May 2020 05:04:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trouble-Entering-Data-Text-String-With-Spaces/m-p/648761#M194402</guid>
      <dc:creator>NKormanik</dc:creator>
      <dc:date>2020-05-19T05:04:51Z</dc:date>
    </item>
  </channel>
</rss>

