<?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 handle special characters in data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-handle-special-characters-in-data/m-p/512852#M138163</link>
    <description>&lt;P&gt;Here is my solution&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ii;
  /* Input the record into memory (_INFILE_) but do not release it */
  input @; 
  /* Remove the $ sign from the record */
  _infile_ = translate(_infile_,' ','$');
  /* Read the record again and skip the ***** line using the slash sign (/) */
  input ID $ BirthDay :date9. Salary comma10.0 /;
  /* Create derived variables */
  Dept = substr(ID,1,1);
  Year = year(BirthDay);
  format BirthDay date9. Salary comma10.0 ;
  datalines;
A123 4Mar1989 8,6,00
***************
 A037 23Jun1957 21,450
**************
 M015 19Sep1977$17,500
***********
;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I am assuming that every other line is a line with only ***************&lt;/P&gt;</description>
    <pubDate>Wed, 14 Nov 2018 07:19:27 GMT</pubDate>
    <dc:creator>MichaelLarsen</dc:creator>
    <dc:date>2018-11-14T07:19:27Z</dc:date>
    <item>
      <title>How to handle special characters in data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-handle-special-characters-in-data/m-p/512848#M138159</link>
      <description>&lt;P&gt;Hi all&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Im having trouble creating a dataset from a txt.file, where * and $ is amongst my variables.&lt;/P&gt;&lt;P&gt;The data:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;(ii);
A123  4Mar1989  8,6,00
***************
    A037 23Jun1957  21,450
**************
 M015 19Sep1977$17,500
***********&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Code so far:&lt;/P&gt;&lt;PRE&gt;data ii;
  input DEPT $1. @1 ID $ BIRTHDAY :date9. +(-5) YEAR :8. SALARY comma10.0;
  datalines;
A123 4Mar1989 8,6,00&lt;BR /&gt;***************&lt;BR /&gt; A037 23Jun1957 21,450&lt;BR /&gt;**************&lt;BR /&gt; M015 19Sep1977$17,500&lt;BR /&gt;***********
;
run;&lt;/PRE&gt;&lt;P&gt;However this loads the *** and the $ as missing characters.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The first record should&amp;nbsp;be:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;ID = "A123", DEPT = "A", BIRTHDAY = 10655, YEAR = 1989, SALARY = 8600&lt;/CODE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Any suggestions?&lt;/P&gt;</description>
      <pubDate>Wed, 14 Nov 2018 07:03:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-handle-special-characters-in-data/m-p/512848#M138159</guid>
      <dc:creator>torvin10</dc:creator>
      <dc:date>2018-11-14T07:03:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to handle special characters in data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-handle-special-characters-in-data/m-p/512852#M138163</link>
      <description>&lt;P&gt;Here is my solution&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ii;
  /* Input the record into memory (_INFILE_) but do not release it */
  input @; 
  /* Remove the $ sign from the record */
  _infile_ = translate(_infile_,' ','$');
  /* Read the record again and skip the ***** line using the slash sign (/) */
  input ID $ BirthDay :date9. Salary comma10.0 /;
  /* Create derived variables */
  Dept = substr(ID,1,1);
  Year = year(BirthDay);
  format BirthDay date9. Salary comma10.0 ;
  datalines;
A123 4Mar1989 8,6,00
***************
 A037 23Jun1957 21,450
**************
 M015 19Sep1977$17,500
***********
;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I am assuming that every other line is a line with only ***************&lt;/P&gt;</description>
      <pubDate>Wed, 14 Nov 2018 07:19:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-handle-special-characters-in-data/m-p/512852#M138163</guid>
      <dc:creator>MichaelLarsen</dc:creator>
      <dc:date>2018-11-14T07:19:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to handle special characters in data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-handle-special-characters-in-data/m-p/512853#M138164</link>
      <description>&lt;P&gt;And if the occurence of the ****** lines is irregular, here a slight variation of &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/24960"&gt;@MichaelLarsen&lt;/a&gt;'s code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ii;
  /* Input the record into memory (_INFILE_) but do not release it */
  input @; 
  if not index(_infile_,'****');
  /* Remove the $ sign from the record */
  _infile_ = translate(_infile_,' ','$');
  /* Read the record again */
  input ID $ BirthDay :date9. Salary comma10.0;
  /* Create derived variables */
  Dept = substr(ID,1,1);
  Year = year(BirthDay);
  format BirthDay date9. Salary comma10.0 ;
  datalines;
A123 4Mar1989 8,6,00
***************
 A037 23Jun1957 21,450
**************
 M015 19Sep1977$17,500
***********
;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 14 Nov 2018 07:26:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-handle-special-characters-in-data/m-p/512853#M138164</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-11-14T07:26:04Z</dc:date>
    </item>
  </channel>
</rss>

