<?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 replace the asterisk to a number &amp;quot;-99&amp;quot;? in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-replace-the-asterisk-to-a-number-quot-99-quot/m-p/287514#M8181</link>
    <description>&lt;P&gt;Here is another approach using a custom informat.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format library=work;
invalue da
'*'=-99
other=_same_;
run;

data example;
   informat x $5.;
   input x ;
   coverage = input(x,da.);
datalines;
1
2
3
4
*
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You still need to have the resulting variable with a different name than that&amp;nbsp;existing in you current data though.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you were to end up having multiple codes you needed clean such as "**" then the Tranward approach requires multiple lines of code and order is going to be important (you wouldn't want to replace ** with -99-99 if the intent was ** maps to -999). The format approach would allow adding multiple replacements in the informat construction (not to mention multiple values to the same result) and only one line of code in the manipulation step.&lt;/P&gt;</description>
    <pubDate>Wed, 27 Jul 2016 16:06:40 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2016-07-27T16:06:40Z</dc:date>
    <item>
      <title>How to replace the asterisk to a number "-99"?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-replace-the-asterisk-to-a-number-quot-99-quot/m-p/287377#M8177</link>
      <description>&lt;P&gt;Hello:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the following dataset. &amp;nbsp; After I import them into SAS, the variable "coverage" become characterized. &amp;nbsp; I would like to replace the asterisk * with -99. &amp;nbsp;I wrote a quote below. &amp;nbsp;But one error message was shown in the log page, &amp;nbsp;It said that the "Coverage1" was uninitiated.&amp;nbsp; Why won't it happen? &amp;nbsp;How to resolve&amp;nbsp;it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Jurisdiction-Level Coverage &lt;/SPAN&gt;&lt;BR /&gt;Alabama &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3&lt;BR /&gt;Alaska &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;BR /&gt;Arizona &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3&lt;BR /&gt;Arkansas &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3&lt;BR /&gt;California &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Colorado &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Connecticut &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Delaware &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;District of Columbia 1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Florida &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; *&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Georgia &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; *&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;459 data test (drop=coverage);&lt;BR /&gt;460 length coverage $4.;&lt;BR /&gt;461 set test;&lt;BR /&gt;462 coverage=tranwrd(coverage1,'*','-99');&lt;BR /&gt;463 coverage=input(coverage1, 4.);&lt;BR /&gt;464 run;&lt;BR /&gt;&lt;BR /&gt;NOTE: Numeric values have been converted to character values at the places given by:&lt;BR /&gt;(Line):(Column).&lt;BR /&gt;462:33 463:25 463:31&lt;BR /&gt;NOTE: Variable coverage1 is uninitialized.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jul 2016 23:58:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-replace-the-asterisk-to-a-number-quot-99-quot/m-p/287377#M8177</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2016-07-26T23:58:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace the asterisk to a number "-99"?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-replace-the-asterisk-to-a-number-quot-99-quot/m-p/287380#M8178</link>
      <description>&lt;P&gt;You can't have "Coverage" as a character and a numeric variable in the same data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I do in this situation is rename the incoming variable in the "set" statement, something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;set test(rename=(coverage=coverage_char));&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and then&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;coverage_char=tranwrd(coverage_char,'*','-99');&lt;BR /&gt;coverage=input(coverage_char, 4.);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;coverage=input(tranwrd(coverage_char,'*','-99'), 4.);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(untested)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tom&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jul 2016 00:45:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-replace-the-asterisk-to-a-number-quot-99-quot/m-p/287380#M8178</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2016-07-27T00:45:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace the asterisk to a number "-99"?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-replace-the-asterisk-to-a-number-quot-99-quot/m-p/287412#M8179</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test (drop=coverage);
/* the drop means that the variable "coverage" COMING FROM THE DATA STEP will not be included in the output dataset; this makes the whole data step useless */
length coverage $4.;
set test;
coverage=tranwrd(coverage1,'*','-99');
coverage=input(coverage1, 4.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You probably wanted this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test (drop=coverage1 coverage2);
set test (rename=(coverage=coverage1));
coverage2=tranwrd(coverage1,'*','-99');
coverage=input(coverage2, 4.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I used coverage2 because you can't rely on coverage1 (the old coverage) being long enough to hold the '-99' string.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jul 2016 05:19:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-replace-the-asterisk-to-a-number-quot-99-quot/m-p/287412#M8179</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-07-27T05:19:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace the asterisk to a number "-99"?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-replace-the-asterisk-to-a-number-quot-99-quot/m-p/287514#M8181</link>
      <description>&lt;P&gt;Here is another approach using a custom informat.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format library=work;
invalue da
'*'=-99
other=_same_;
run;

data example;
   informat x $5.;
   input x ;
   coverage = input(x,da.);
datalines;
1
2
3
4
*
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You still need to have the resulting variable with a different name than that&amp;nbsp;existing in you current data though.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you were to end up having multiple codes you needed clean such as "**" then the Tranward approach requires multiple lines of code and order is going to be important (you wouldn't want to replace ** with -99-99 if the intent was ** maps to -999). The format approach would allow adding multiple replacements in the informat construction (not to mention multiple values to the same result) and only one line of code in the manipulation step.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jul 2016 16:06:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-replace-the-asterisk-to-a-number-quot-99-quot/m-p/287514#M8181</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-07-27T16:06:40Z</dc:date>
    </item>
  </channel>
</rss>

