<?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: Create a SAS table with a  character column containing &amp;quot;longer&amp;quot; text in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-a-SAS-table-with-a-character-column-containing-quot/m-p/862501#M340702</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
   LENGTH date 8 customer_id 8 segment_generation_1 $ 100 segment_generation_2 $ 1 ;
   input date :yymmdd10. customer_id segment_generation_1 $ segment_generation_2 $ ;
   format date yymmdd10.;
   datalines;
2023-01-15 111 REPLACED_BY_GENERATION_2 B
2023-01-15 222 REPLACED_BY_GENERATION_2 B
2023-01-15 333 REPLACED_BY_GENERATION_2 B
;
run;

proc print; run;
/* end of program */&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 06 Mar 2023 15:48:39 GMT</pubDate>
    <dc:creator>sbxkoenk</dc:creator>
    <dc:date>2023-03-06T15:48:39Z</dc:date>
    <item>
      <title>Create a SAS table with a  character column containing "longer" text</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-SAS-table-with-a-character-column-containing-quot/m-p/862499#M340700</link>
      <description>&lt;P&gt;Want to create a SAS table of the form:&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;TABLE width="751"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="242"&gt;date&lt;/TD&gt;
&lt;TD width="171"&gt;customer_id&lt;/TD&gt;
&lt;TD width="185"&gt;segment_generation_1&lt;/TD&gt;
&lt;TD width="153"&gt;segment_generation_2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;2023-01-15&lt;/TD&gt;
&lt;TD&gt;111&lt;/TD&gt;
&lt;TD&gt;REPLACED BY GENERATION 2&lt;/TD&gt;
&lt;TD&gt;B&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;2023-01-15&lt;/TD&gt;
&lt;TD&gt;222&lt;/TD&gt;
&lt;TD&gt;REPLACED BY GENERATION 2&lt;/TD&gt;
&lt;TD&gt;B&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;2023-01-15&lt;/TD&gt;
&lt;TD&gt;333&lt;/TD&gt;
&lt;TD&gt;REPLACED BY GENERATION 2&lt;/TD&gt;
&lt;TD&gt;B&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&lt;BR /&gt;SAS code I tried (that does not work):&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
   input date :yymmdd10. customer_id segment_generation_1 $char100.  segment_generation_2 $ ;
   format date yymmdd10.;
   datalines;
   2023-01-15 111 REPLACED_BY_GENERATION_2 B
   2023-01-15 222 REPLACED_BY_GENERATION_2 B
   2023-01-15 333 REPLACED_BY_GENERATION_2 B
   ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Any advice?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Mar 2023 15:44:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-SAS-table-with-a-character-column-containing-quot/m-p/862499#M340700</guid>
      <dc:creator>SasStatistics</dc:creator>
      <dc:date>2023-03-06T15:44:01Z</dc:date>
    </item>
    <item>
      <title>Re: Create a SAS table with a  character column containing "longer" text</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-SAS-table-with-a-character-column-containing-quot/m-p/862501#M340702</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
   LENGTH date 8 customer_id 8 segment_generation_1 $ 100 segment_generation_2 $ 1 ;
   input date :yymmdd10. customer_id segment_generation_1 $ segment_generation_2 $ ;
   format date yymmdd10.;
   datalines;
2023-01-15 111 REPLACED_BY_GENERATION_2 B
2023-01-15 222 REPLACED_BY_GENERATION_2 B
2023-01-15 333 REPLACED_BY_GENERATION_2 B
;
run;

proc print; run;
/* end of program */&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 06 Mar 2023 15:48:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-SAS-table-with-a-character-column-containing-quot/m-p/862501#M340702</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2023-03-06T15:48:39Z</dc:date>
    </item>
    <item>
      <title>Re: Create a SAS table with a  character column containing "longer" text</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-SAS-table-with-a-character-column-containing-quot/m-p/862511#M340705</link>
      <description>&lt;P&gt;You need to use LIST MODE input instead of FORMATTED MODE input to read variable length strings from text lines.&lt;/P&gt;
&lt;P&gt;You are already doing that for the DATE variable by using the colon modifier before the informat sepecified in the INPUT statement.&amp;nbsp; So you could try doing the same thing for your other variable. You also probably want to use the normal $ informat and not the specialized $CHAR informat. I doubt that you want to preserve leading spaces in the values, or treat override the default behaviour of treating as single period as indicating a missing value.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;input date :yymmdd10. customer_id segment_generation_1 :$100.  segment_generation_2 $ ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;For your example data lines you could also use FORMATTED MODE or COLUMN MODE since the fields appear to be aligned nicely into fixed positions on the line.&amp;nbsp; In that case you need to actually DEFINE the variable before the INPUT statement, instead of forcing SAS to GUESS how you wanted it to define the variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;NOTE: You also should NEVER indent the lines of data!!&amp;nbsp; To remind yourself do not indent the DATALINES (aka CARDS) statement either.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
   length date 8 customer_id 8 segment_generation_1 segment_generation_2 $100;
   input date yymmdd10. customer_id 5. segment_generation_1 $25..  segment_generation_2 $25.;
 * input @1 date yymmdd10. customer_id 12-15 segment_generation_1 $ 16-40  segment_generation_2 $ 41-55 ;
   format date yymmdd10.;
datalines;
2023-01-15 111 REPLACED_BY_GENERATION_2 B
2023-01-15 222 REPLACED_BY_GENERATION_2 B
2023-01-15 333 REPLACED_BY_GENERATION_2 B
;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you have data lines that do not align to fixed column you will probably have trouble also with values like your example listing that have embedded spaces in the value.&amp;nbsp; You probably will want to use a different delimiter than a space so you can use DSD option.&amp;nbsp; That also will support adding quotes in the text around values that happen to include the delimiter.&lt;/P&gt;
&lt;P&gt;Notice also that if you have defined all of the variables (and in the order they appear in the data lines) the INPUT statement can be much simpler.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
   infile datalines dsd truncover;
   length date 8 customer_id 8 segment_generation_1 segment_generation_2 $100;
   informat date yymmdd10.;
   format date yymmdd10.;
   input date -- segment_generation_2;
datalines;
2023-01-15,111,REPLACED_BY_GENERATION_2,B
2023-01-15,222,"This value was replaced, by generation2",B
2023-01-15,333,REPLACED_BY_GENERATION_2,B
;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 06 Mar 2023 16:12:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-SAS-table-with-a-character-column-containing-quot/m-p/862511#M340705</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-03-06T16:12:23Z</dc:date>
    </item>
  </channel>
</rss>

