<?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: why do i have character values for numeric format? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/why-do-i-have-character-values-for-numeric-format/m-p/670741#M201392</link>
    <description>thank you!</description>
    <pubDate>Mon, 20 Jul 2020 18:10:03 GMT</pubDate>
    <dc:creator>HitmonTran</dc:creator>
    <dc:date>2020-07-20T18:10:03Z</dc:date>
    <item>
      <title>why do i have character values for numeric format?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/why-do-i-have-character-values-for-numeric-format/m-p/670331#M201198</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the raw dataset is giving character values for numeric variables. So when I&amp;nbsp;convert&amp;nbsp;numeric values to character, different values&amp;nbsp;display.&amp;nbsp;I tried using "encoding=any" when reading in the data&amp;nbsp;but it does not solve the problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;col8,col9,col10 are derived variables from the numeric variables (prdvplc1, prpain1, pryn14) using put function&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 541px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/47279iE5F8FD7B915A61B3/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 18 Jul 2020 16:15:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/why-do-i-have-character-values-for-numeric-format/m-p/670331#M201198</guid>
      <dc:creator>HitmonTran</dc:creator>
      <dc:date>2020-07-18T16:15:24Z</dc:date>
    </item>
    <item>
      <title>Re: why do i have character values for numeric format?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/why-do-i-have-character-values-for-numeric-format/m-p/670334#M201199</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;col8,col9,col10 are derived variables from the numeric variables (prdvplc1, prpain1, pryn14) using put function&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PUT always results in a character variable.&lt;/P&gt;</description>
      <pubDate>Sat, 18 Jul 2020 16:22:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/why-do-i-have-character-values-for-numeric-format/m-p/670334#M201199</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-07-18T16:22:37Z</dc:date>
    </item>
    <item>
      <title>Re: why do i have character values for numeric format?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/why-do-i-have-character-values-for-numeric-format/m-p/670335#M201200</link>
      <description>but how do I retain the values of "Easy, Very Easy, Very Hard" when using put function for variable PRDVPLC1</description>
      <pubDate>Sat, 18 Jul 2020 16:25:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/why-do-i-have-character-values-for-numeric-format/m-p/670335#M201200</guid>
      <dc:creator>HitmonTran</dc:creator>
      <dc:date>2020-07-18T16:25:43Z</dc:date>
    </item>
    <item>
      <title>Re: why do i have character values for numeric format?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/why-do-i-have-character-values-for-numeric-format/m-p/670336#M201201</link>
      <description>&lt;P&gt;Which variables in your photograph are numeric and which are character? Are we supposed to tell that from the icons? Are the icons to the right or the left of variable names?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to create a character variable with the decoded value of the variable either use the same format in the PUT() or PUTN() function call or use the VVALUE() or VVALUEX() function.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have ;
  pyn14_raw = pyn14 ;
  pyn14_char1 = put(pyn14,yesno.);
  pyn14_char2 = putn(pyn14,'yesno.');
  pyn14_char3 = vvalue(pyn14);
  pyn14_char4 = vvaluex('pyn14');
run;

proc print;
  var pyn14: ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 18 Jul 2020 16:26:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/why-do-i-have-character-values-for-numeric-format/m-p/670336#M201201</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-07-18T16:26:55Z</dc:date>
    </item>
    <item>
      <title>Re: why do i have character values for numeric format?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/why-do-i-have-character-values-for-numeric-format/m-p/670337#M201202</link>
      <description>this was my logic:&lt;BR /&gt;col8=strip(put(prdvplc1,best.));&lt;BR /&gt;col9=strip(put(pryn14,best.));&lt;BR /&gt;col10=strip(put(prpain1,best.));</description>
      <pubDate>Sat, 18 Jul 2020 16:31:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/why-do-i-have-character-values-for-numeric-format/m-p/670337#M201202</guid>
      <dc:creator>HitmonTran</dc:creator>
      <dc:date>2020-07-18T16:31:20Z</dc:date>
    </item>
    <item>
      <title>Re: why do i have character values for numeric format?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/why-do-i-have-character-values-for-numeric-format/m-p/670339#M201204</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/111564"&gt;@HitmonTran&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;this was my logic:&lt;BR /&gt;col8=strip(put(prdvplc1,best.));&lt;BR /&gt;col9=strip(put(pryn14,best.));&lt;BR /&gt;col10=strip(put(prpain1,best.));&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So you wanted COL9 to be a character string that represents the raw value of PRYN14?&amp;nbsp; Is your question why sometimes the value contains letters?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since you didn't tell SAS what width to use with the BEST format it will default to 12 bytes. If the value is can be represent exactly in 12 characters then the result will only contain digits and possibly a decimal point and/or a minus sign.&amp;nbsp; But if the value cannot then BEST will use scientific notation. So for some values your string might contain the letter E.&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the value is a special missing, like .A or .Z or ._ then the value will be that character (without the period required when specifying the value in SAS code).&lt;/P&gt;</description>
      <pubDate>Sat, 18 Jul 2020 16:38:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/why-do-i-have-character-values-for-numeric-format/m-p/670339#M201204</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-07-18T16:38:24Z</dc:date>
    </item>
    <item>
      <title>Re: why do i have character values for numeric format?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/why-do-i-have-character-values-for-numeric-format/m-p/670341#M201206</link>
      <description>basically I want col8 to have values of ''Easy", "Very Easy", "Very Hard".</description>
      <pubDate>Sat, 18 Jul 2020 16:50:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/why-do-i-have-character-values-for-numeric-format/m-p/670341#M201206</guid>
      <dc:creator>HitmonTran</dc:creator>
      <dc:date>2020-07-18T16:50:15Z</dc:date>
    </item>
    <item>
      <title>Re: why do i have character values for numeric format?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/why-do-i-have-character-values-for-numeric-format/m-p/670343#M201207</link>
      <description>&lt;P&gt;That is what my first answer does. So to get those values you need to use the format that generates them in the PUT() function, not the BEST format.&amp;nbsp; If you don't know what format is attached to your existing variable to make it display that way then use the VVALUE() function instead of the PUT() function.&lt;/P&gt;</description>
      <pubDate>Sat, 18 Jul 2020 16:52:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/why-do-i-have-character-values-for-numeric-format/m-p/670343#M201207</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-07-18T16:52:56Z</dc:date>
    </item>
    <item>
      <title>Re: why do i have character values for numeric format?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/why-do-i-have-character-values-for-numeric-format/m-p/670349#M201211</link>
      <description>&lt;P&gt;It is absolutely not clear what input you have and what output you want.&lt;/P&gt;
&lt;P&gt;You had just posted the undesired output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please post next information:&lt;/P&gt;
&lt;P&gt;1) Is the input a sas dataset or an external file&lt;/P&gt;
&lt;P&gt;2) Is the output a report? an external file? or a new dataset?&lt;/P&gt;
&lt;P&gt;3) If the input is a sas dataset, are those columns col8-col10 of&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;a numeric type or a character type?&lt;/P&gt;
&lt;P&gt;4) post the input value of those columns and the wanted value of each of them?&lt;/P&gt;
&lt;P&gt;5) post your code to create the output&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 18 Jul 2020 17:31:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/why-do-i-have-character-values-for-numeric-format/m-p/670349#M201211</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2020-07-18T17:31:04Z</dc:date>
    </item>
    <item>
      <title>Re: why do i have character values for numeric format?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/why-do-i-have-character-values-for-numeric-format/m-p/670351#M201213</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/111564"&gt;@HitmonTran&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;basically I want col8 to have values of ''Easy", "Very Easy", "Very Hard".&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;Create a format by next code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc format lib=work;
     value is_easy
       1  = "Very Easy"
       2 = "Easy"
       5 = "Very Hard"
  ; run;

data want;
   set have;
         length new_var $10;
         new_var = put(var , is_easy.);  /* var should be num type */
    ...
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 18 Jul 2020 17:41:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/why-do-i-have-character-values-for-numeric-format/m-p/670351#M201213</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2020-07-18T17:41:02Z</dc:date>
    </item>
    <item>
      <title>Re: why do i have character values for numeric format?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/why-do-i-have-character-values-for-numeric-format/m-p/670373#M201225</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/111564"&gt;@HitmonTran&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;but how do I retain the values of "Easy, Very Easy, Very Hard" when using put function for variable PRDVPLC1&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;How do you retain the values? You use variable PRDVPLC1, you don't convert to another variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;or you might be better off using formats&lt;/P&gt;</description>
      <pubDate>Sat, 18 Jul 2020 20:02:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/why-do-i-have-character-values-for-numeric-format/m-p/670373#M201225</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-07-18T20:02:58Z</dc:date>
    </item>
    <item>
      <title>Re: why do i have character values for numeric format?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/why-do-i-have-character-values-for-numeric-format/m-p/670416#M201248</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/111564"&gt;@HitmonTran&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Reading through this thread I believe the bit you're missing is that variable PRDVPLC1 is already numerical and the INTERNAL values will just be numbers. The blue icon in the data grid shows you that the variable is of type numeric. Such variables can't and will never store text.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1595121254730.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/47295iC478FDD786C01D46/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1595121254730.png" alt="Patrick_0-1595121254730.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;You see text in the data grid because there must be a permanent format applied on variable PRDVPLC1. A format doesn't change the internal values but it changes how the values get displayed/printed.&lt;/P&gt;
&lt;P&gt;You can always chose to change the format.&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;Proc Print data=&amp;lt;your data&amp;gt;; format prdvplc1 best32.; var prdvplc1; run;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;...will print the values showing you the digits and not text.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For creating your variable col8 you can do one of below two things:&lt;/P&gt;
&lt;P&gt;1. To create another numerical variable.&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;col8=prdvplc1;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;format col8 &amp;lt;name of format&amp;gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;2. To create a character variable containing the displayed values of the source variable&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;col8=put(prdvplc1, &amp;lt;name of format&amp;gt;.);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To get the name of the format: Run a Proc Contents on your table. That will show you the format name attached to variable prdvplc1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And last but not least: Many procedures allow you to chose if you want to use the formatted or unformatted values for calculations so often there is no need to "duplicate" columns.&lt;/P&gt;</description>
      <pubDate>Sun, 19 Jul 2020 01:29:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/why-do-i-have-character-values-for-numeric-format/m-p/670416#M201248</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-07-19T01:29:51Z</dc:date>
    </item>
    <item>
      <title>Re: why do i have character values for numeric format?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/why-do-i-have-character-values-for-numeric-format/m-p/670741#M201392</link>
      <description>thank you!</description>
      <pubDate>Mon, 20 Jul 2020 18:10:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/why-do-i-have-character-values-for-numeric-format/m-p/670741#M201392</guid>
      <dc:creator>HitmonTran</dc:creator>
      <dc:date>2020-07-20T18:10:03Z</dc:date>
    </item>
  </channel>
</rss>

