<?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: How to read a character variable with a multiple embedded blanks. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-character-variable-with-a-multiple-embedded-blanks/m-p/468525#M119684</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/214263"&gt;@Vibhaa&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Can you please explain why it didn't give the expected result if I provide the length by using length statement instead of specifying it in input statement ?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The INPUT statement is what is controlling how to read the source text into the variables.&amp;nbsp; It does not matter whether or not you have previously defined the variables.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you don't define the variables before you reference them in the INPUT statement then SAS will have to guess how to define them based on how you first use them.&amp;nbsp; That is why you will INPUT statements with a bare $ character after a variable. That let's SAS know that you want that variable to be character.&amp;nbsp; If you have already defined the variable as character then you do not need to add the $ to the INPUT statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 07 Jun 2018 20:47:59 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2018-06-07T20:47:59Z</dc:date>
    <item>
      <title>How to read a character variable with a multiple embedded blanks.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-character-variable-with-a-multiple-embedded-blanks/m-p/468467#M119658</link>
      <description>&lt;P&gt;Hi All,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to know how to read a character variable with a multiple embedded blanks. I have the following data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="multiple_blanks.png" style="width: 389px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/21095iC2566A9F44D37A15/image-size/large?v=v2&amp;amp;px=999" role="button" title="multiple_blanks.png" alt="multiple_blanks.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I want to create a data-set having a variable that store the above data in 9 observations. I have tried the below code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data test;
infile datalines ;
length var1 $ 30.;
input var1 &amp;amp; $ ;
datalines;
ISUGI     2006San Francisco CA
SPHARMASUG2006Bonita SpringsFL
RNESUG    2006Philadelphia  PA
RWUSS     2006Irvine        CA
RSESUG    2006Atlanta       GA
RSCSUG    2006Irving        TX
RMWSUG    2006Dearborn      MI
RPNWSUG   2006Seaside       OR
ISUGI     2007Orlando       FL
;
run;&lt;/PRE&gt;&lt;P&gt;Ouput:&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="multiple_blank2.png" style="width: 257px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/21096iC43898DD272B7375/image-size/large?v=v2&amp;amp;px=999" role="button" title="multiple_blank2.png" alt="multiple_blank2.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But the char after the multiple blanks are not store in that variable.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I am not able to figure out what code to use in order to accomplish this task. Could anyone please help me by providing a code &amp;nbsp;that could accomplish the above task? If you need more information, please ask. Would appreciate your help. I am using sas version 9.4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;Vibha&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, 07 Jun 2018 17:42:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-character-variable-with-a-multiple-embedded-blanks/m-p/468467#M119658</guid>
      <dc:creator>Vibhaa</dc:creator>
      <dc:date>2018-06-07T17:42:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to read a character variable with a multiple embedded blanks.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-character-variable-with-a-multiple-embedded-blanks/m-p/468474#M119661</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
/*infile datalines ;*/
/*length var1 $ 30.;*/
/*input var1 &amp;amp; $ ;*/
input var1 $30.;
datalines;
ISUGI     2006San Francisco CA
SPHARMASUG2006Bonita SpringsFL
RNESUG    2006Philadelphia  PA
RWUSS     2006Irvine        CA
RSESUG    2006Atlanta       GA
RSCSUG    2006Irving        TX
RMWSUG    2006Dearborn      MI
RPNWSUG   2006Seaside       OR
ISUGI     2007Orlando       FL
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Jun 2018 17:55:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-character-variable-with-a-multiple-embedded-blanks/m-p/468474#M119661</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-06-07T17:55:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to read a character variable with a multiple embedded blanks.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-character-variable-with-a-multiple-embedded-blanks/m-p/468479#M119662</link>
      <description>&lt;P&gt;Can you please explain why it didn't give the expected result if I provide the length by using length statement instead of specifying it in input statement ?&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jun 2018 18:10:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-character-variable-with-a-multiple-embedded-blanks/m-p/468479#M119662</guid>
      <dc:creator>Vibhaa</dc:creator>
      <dc:date>2018-06-07T18:10:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to read a character variable with a multiple embedded blanks.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-character-variable-with-a-multiple-embedded-blanks/m-p/468481#M119663</link>
      <description>&lt;P&gt;That data looks like it is in columns. I looks like there are actually five variables there.&lt;/P&gt;
&lt;P&gt;So use column based input statement.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  input type $ 1
        name $ 2-10
        year 11-14
        city $ 15-28
        state $ 29-30
   ;
datalines;
ISUGI     2006San Francisco CA
SPHARMASUG2006Bonita SpringsFL
RNESUG    2006Philadelphia  PA
RWUSS     2006Irvine        CA
RSESUG    2006Atlanta       GA
RSCSUG    2006Irving        TX
RMWSUG    2006Dearborn      MI
RPNWSUG   2006Seaside       OR
ISUGI     2007Orlando       FL
;
run;
proc print; run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;Obs    type    name         year    city              state

1      I      SUGI         2006    San Francisco      CA
2      S      PHARMASUG    2006    Bonita Springs     FL
3      R      NESUG        2006    Philadelphia       PA
4      R      WUSS         2006    Irvine             CA
5      R      SESUG        2006    Atlanta            GA
6      R      SCSUG        2006    Irving             TX
7      R      MWSUG        2006    Dearborn           MI
8      R      PNWSUG       2006    Seaside            OR
9      I      SUGI         2007    Orlando            FL
&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Jun 2018 18:14:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-character-variable-with-a-multiple-embedded-blanks/m-p/468481#M119663</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-06-07T18:14:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to read a character variable with a multiple embedded blanks.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-character-variable-with-a-multiple-embedded-blanks/m-p/468483#M119664</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/214263"&gt;@Vibhaa&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Can you please explain why it didn't give the expected result if I provide the length by using length statement instead of specifying it in input statement ?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;With normal list mode input SAS will read up to the next delimiter (space is the default delimiter). If you add the &amp;amp; modifier then it will skip single delimiters and read up until two or more delimiters.&lt;/P&gt;
&lt;P&gt;With formatted input mode SAS will read the number of characters you tell it to read. Whether they contain delimiters or not.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jun 2018 18:20:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-character-variable-with-a-multiple-embedded-blanks/m-p/468483#M119664</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-06-07T18:20:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to read a character variable with a multiple embedded blanks.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-character-variable-with-a-multiple-embedded-blanks/m-p/468525#M119684</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/214263"&gt;@Vibhaa&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Can you please explain why it didn't give the expected result if I provide the length by using length statement instead of specifying it in input statement ?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The INPUT statement is what is controlling how to read the source text into the variables.&amp;nbsp; It does not matter whether or not you have previously defined the variables.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you don't define the variables before you reference them in the INPUT statement then SAS will have to guess how to define them based on how you first use them.&amp;nbsp; That is why you will INPUT statements with a bare $ character after a variable. That let's SAS know that you want that variable to be character.&amp;nbsp; If you have already defined the variable as character then you do not need to add the $ to the INPUT statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jun 2018 20:47:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-character-variable-with-a-multiple-embedded-blanks/m-p/468525#M119684</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-06-07T20:47:59Z</dc:date>
    </item>
  </channel>
</rss>

