<?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: Variable keeps generating with * as result in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Variable-keeps-generating-with-as-result/m-p/842531#M333151</link>
    <description>&lt;P&gt;Check what display format you have attached to the variable.&lt;/P&gt;
&lt;P&gt;I can recreate what you seem to be describing by just attaching a format that&amp;nbsp; uses a width that is too small to display 99.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  variable=99;
  format variable 1.;
run;

proc freq data=test;
  tables variable;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;The FREQ Procedure

                                     Cumulative    Cumulative
variable    Frequency     Percent     Frequency      Percent
-------------------------------------------------------------
       *           1      100.00             1       100.00
&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;Note&lt;/STRONG&gt; that most SAS variables do NOT need to have a format attached.&amp;nbsp; The exception is DATE, TIME and DATETIME values that are hard for humans to understand without using a format to display them.&amp;nbsp; If you want to just remove the formats from a variable (or multiple variables) then use a FORMAT statement that lists variables but does not include any format specification after the list.&amp;nbsp; You can use the _ALL_ keyword to remove the formats from ALL of the variables.&amp;nbsp; You could then add a second format statement to add back any formats that are needed.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;format _all_ ;
format datevar date9.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 04 Nov 2022 15:56:17 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2022-11-04T15:56:17Z</dc:date>
    <item>
      <title>Variable keeps generating with * as result</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-keeps-generating-with-as-result/m-p/842403#M333106</link>
      <description>&lt;P&gt;I give up, this one doesn't make sense to me.&amp;nbsp; I have a variable in a dataset that is all missing.&lt;/P&gt;&lt;P&gt;I need it to recode to 99, the code for does not collect.&amp;nbsp; I've tried a number of variations.&lt;/P&gt;&lt;P&gt;Dropping the variable beforehand and then adding it back, If/Then logic.&amp;nbsp; Everything keeps generating * when I run a proc freq.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's my basic code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; variable = 99;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Nov 2022 20:33:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-keeps-generating-with-as-result/m-p/842403#M333106</guid>
      <dc:creator>DanielQuay</dc:creator>
      <dc:date>2022-11-03T20:33:10Z</dc:date>
    </item>
    <item>
      <title>Re: Variable keeps generating with * as result</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-keeps-generating-with-as-result/m-p/842406#M333107</link>
      <description>What is the type of the variable (character/numeric) and can you show the log please?</description>
      <pubDate>Thu, 03 Nov 2022 20:40:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-keeps-generating-with-as-result/m-p/842406#M333107</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-11-03T20:40:46Z</dc:date>
    </item>
    <item>
      <title>Re: Variable keeps generating with * as result</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-keeps-generating-with-as-result/m-p/842407#M333108</link>
      <description>&lt;P&gt;Well that's probably it, it's a character variable.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will try to get you the log on that, but I have to clean up the log a bit first.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Nov 2022 20:44:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-keeps-generating-with-as-result/m-p/842407#M333108</guid>
      <dc:creator>DanielQuay</dc:creator>
      <dc:date>2022-11-03T20:44:45Z</dc:date>
    </item>
    <item>
      <title>Re: Variable keeps generating with * as result</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-keeps-generating-with-as-result/m-p/842408#M333109</link>
      <description>Then your code should read variable = '99'; at minimum. &lt;BR /&gt;</description>
      <pubDate>Thu, 03 Nov 2022 20:49:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-keeps-generating-with-as-result/m-p/842408#M333109</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-11-03T20:49:08Z</dc:date>
    </item>
    <item>
      <title>Re: Variable keeps generating with * as result</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-keeps-generating-with-as-result/m-p/842412#M333110</link>
      <description>&lt;P&gt;Since you mention PROC freq, check that you don't have a format changing the value displayed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=want;
  tables variable;
  format variable;  *remove any format attached;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 03 Nov 2022 21:18:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-keeps-generating-with-as-result/m-p/842412#M333110</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2022-11-03T21:18:36Z</dc:date>
    </item>
    <item>
      <title>Re: Variable keeps generating with * as result</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-keeps-generating-with-as-result/m-p/842528#M333148</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/205036"&gt;@DanielQuay&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I give up, this one doesn't make sense to me.&amp;nbsp; I have a variable in a dataset that is all missing.&lt;/P&gt;
&lt;P&gt;I need it to recode to 99, the code for does not collect.&amp;nbsp; I've tried a number of variations.&lt;/P&gt;
&lt;P&gt;Dropping the variable beforehand and then adding it back, If/Then logic.&amp;nbsp; Everything keeps generating * when I run a proc freq.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's my basic code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;set have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; variable = 99;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Show us the results of Proc Contents for your Have data set. That will help reduce the number of things that we have to guess at. NOT the Want data set, the HAVE, though if the code is as you show there really shouldn't be much difference.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Nov 2022 15:31:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-keeps-generating-with-as-result/m-p/842528#M333148</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-11-04T15:31:35Z</dc:date>
    </item>
    <item>
      <title>Re: Variable keeps generating with * as result</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-keeps-generating-with-as-result/m-p/842531#M333151</link>
      <description>&lt;P&gt;Check what display format you have attached to the variable.&lt;/P&gt;
&lt;P&gt;I can recreate what you seem to be describing by just attaching a format that&amp;nbsp; uses a width that is too small to display 99.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  variable=99;
  format variable 1.;
run;

proc freq data=test;
  tables variable;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;The FREQ Procedure

                                     Cumulative    Cumulative
variable    Frequency     Percent     Frequency      Percent
-------------------------------------------------------------
       *           1      100.00             1       100.00
&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;Note&lt;/STRONG&gt; that most SAS variables do NOT need to have a format attached.&amp;nbsp; The exception is DATE, TIME and DATETIME values that are hard for humans to understand without using a format to display them.&amp;nbsp; If you want to just remove the formats from a variable (or multiple variables) then use a FORMAT statement that lists variables but does not include any format specification after the list.&amp;nbsp; You can use the _ALL_ keyword to remove the formats from ALL of the variables.&amp;nbsp; You could then add a second format statement to add back any formats that are needed.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;format _all_ ;
format datevar date9.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Nov 2022 15:56:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-keeps-generating-with-as-result/m-p/842531#M333151</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-11-04T15:56:17Z</dc:date>
    </item>
    <item>
      <title>Re: Variable keeps generating with * as result</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-keeps-generating-with-as-result/m-p/842534#M333153</link>
      <description>&lt;P&gt;I think this is the code you're wanting from the Log Reeza.&lt;BR /&gt;&lt;BR /&gt;NOTE: There were 69871 observations read from the data set WORK.MODIFY.&lt;BR /&gt;NOTE: The data set WORK.MOD2 has 69871 observations and 186 variables.&lt;BR /&gt;NOTE: At least one W.D format was too small for the number to be printed. The decimal may be shifted&lt;BR /&gt;by the "BEST" format.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.27 seconds&lt;BR /&gt;cpu time 0.23 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There is not formatting applied in the creation of this one.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is what I get when I run the contents:&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV&gt;&lt;DIV align="center"&gt;78 &lt;TABLE cellspacing="0" cellpadding="5"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;HSMRNT_PRVD_TP&lt;/TD&gt;&lt;TD&gt;Char&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;$1.&lt;/TD&gt;&lt;TD&gt;$1.&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 04 Nov 2022 16:09:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-keeps-generating-with-as-result/m-p/842534#M333153</guid>
      <dc:creator>DanielQuay</dc:creator>
      <dc:date>2022-11-04T16:09:58Z</dc:date>
    </item>
    <item>
      <title>Re: Variable keeps generating with * as result</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-keeps-generating-with-as-result/m-p/842535#M333154</link>
      <description>&lt;P&gt;That shows that your variable does have the $1 format attached, as Tom predicted.&amp;nbsp; Please see above suggestions from Tom and me about how to remove the format.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Nov 2022 16:14:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-keeps-generating-with-as-result/m-p/842535#M333154</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2022-11-04T16:14:27Z</dc:date>
    </item>
    <item>
      <title>Re: Variable keeps generating with * as result</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-keeps-generating-with-as-result/m-p/842545#M333158</link>
      <description>&lt;P&gt;So you have a character variable that is only one byte long.&amp;nbsp; There is no way to store the two byte string '99' into that variable.&lt;/P&gt;
&lt;P&gt;You will need to make a NEW variable to change the length (or at least define the length before referencing the old variable via the SET statement).&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What value is it that you want to change to '99'?&amp;nbsp; If cannot be a numeric missing value since the variable is character and not numeric.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;And also (perhaps actually most importantly) why would you WANT to convert a missing value to a non-missing value?&lt;/STRONG&gt;&amp;nbsp; If you did make the variable numeric then storing 99 instead of . (or any of the other 27 special missing values) would make using variable HARDER.&amp;nbsp; You could not use MAX or MIN or MEAN or other statistical operations on it without first eliminating the 99's.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is it possible you created this dataset by using PROC IMPORT?&amp;nbsp; That procedure when reading from a text file or an Excel file will define any variable with all missing values as character with a length of 1 since that takes less space to store than a number.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Nov 2022 17:49:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-keeps-generating-with-as-result/m-p/842545#M333158</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-11-04T17:49:15Z</dc:date>
    </item>
  </channel>
</rss>

