<?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: Format Issue in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Format-Issue/m-p/808233#M318687</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/172279"&gt;@ZahidHussain&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Hi, Thanks for your reply. I got your point. One question this data file originally from CSV. and the one value of the variable is 1.05E+3 (3.02) which is character format. Now my question is how I convert it to numeric format and without scientific notation (E) in SAS?&lt;BR /&gt;Thanks&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;And what number do you think that string means?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-SPOILER&gt;It does not look like a valid number because of the extra characters at the end.&amp;nbsp; So "1.05E+3" is just another way of writing 1050.&amp;nbsp; But the extra character make it an invalid input.&amp;nbsp; What is the meaning of the "(3.02)" at the end?&lt;/LI-SPOILER&gt;</description>
    <pubDate>Sun, 17 Apr 2022 15:31:16 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2022-04-17T15:31:16Z</dc:date>
    <item>
      <title>Format Issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-Issue/m-p/808184#M318668</link>
      <description>&lt;P&gt;HI Folks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am wondering how to format this type of character data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The data is:&lt;/P&gt;&lt;P&gt;data test;&lt;/P&gt;&lt;P&gt;input result $20. ;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;datalines;&lt;/P&gt;&lt;P&gt;&amp;lt; 20&lt;BR /&gt;101&lt;BR /&gt;Target Not Detected&lt;BR /&gt;1.05E+3 (3.02)&lt;BR /&gt;322286&lt;BR /&gt;162&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to decode this value like that:&lt;/P&gt;&lt;P&gt;1 = viral load suppressed (&amp;lt;1000 copies / mL)&lt;BR /&gt;2 = not viral load suppressed&lt;BR /&gt;99 = Missing&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anybody gives me some idea that how can I do that?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Apr 2022 19:16:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-Issue/m-p/808184#M318668</guid>
      <dc:creator>ZahidHussain</dc:creator>
      <dc:date>2022-04-16T19:16:41Z</dc:date>
    </item>
    <item>
      <title>Re: Format Issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-Issue/m-p/808190#M318669</link>
      <description>&lt;P&gt;A format is used to convert values into text.&amp;nbsp; So you could think of them like a decoder ring.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So in your case it looks you want a format to DECODE 1 into '&lt;SPAN&gt;viral load suppressed' etc.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;So something like this (it makes no sense to code missing values as a valid number like 99).&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format ;
  value viral_load 
  1='viral load suppressed (&amp;lt;1000 copies / mL)'
  2='not viral load suppressed'
  .='Missing'
  ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;But the real problem it looks like you are having is how to ENCODE the strings you have into the appropriate codes.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;What is the logic for handling those example strings?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Apr 2022 19:56:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-Issue/m-p/808190#M318669</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-04-16T19:56:00Z</dc:date>
    </item>
    <item>
      <title>Re: Format Issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-Issue/m-p/808208#M318671</link>
      <description>Thanks for your reply. Encoding is problem. The result variable is character which has numeric number as well as character. If I use input function some value would be missing . So my question is, How I do format this variable both has numeric and character value&lt;BR /&gt;</description>
      <pubDate>Sat, 16 Apr 2022 23:27:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-Issue/m-p/808208#M318671</guid>
      <dc:creator>ZahidHussain</dc:creator>
      <dc:date>2022-04-16T23:27:34Z</dc:date>
    </item>
    <item>
      <title>Re: Format Issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-Issue/m-p/808215#M318675</link>
      <description>&lt;P&gt;You posted examples of the free text field you have, but did not provide any rules (or even a sketch of the rules) for categorizing them.&amp;nbsp; You did not even provide the categories you want for the example text you provided.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Keep the text as one variable.&amp;nbsp; You can then convert that into one or two more variables to help you categorize them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example you could start by handling the text that can actually be interpreted as a number.&lt;/P&gt;
&lt;P&gt;So if you have the dataset HAVE with the character variable RESULT.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data HAVE;
  input result $20. ;
datalines;
.
&amp;lt; 20
101
Target Not Detected
1.05E+3 (3.02)
322286
162
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You could create the numeric variable RESULTN and then categorize that.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  resultn=input(result,??32.);
  if missing(result) then category=.;
  else if missing(resultn) then category=.U;
  else if resultn &amp;lt; 1000 then category=1;
  else category=2;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results:&lt;/P&gt;
&lt;PRE&gt;Obs    result                 resultn    category

 1                                  .        .
 2     &amp;lt; 20                         .        U
 3     101                        101        1
 4     Target Not Detected          .        U
 5     1.05E+3 (3.02)               .        U
 6     322286                  322286        2
 7     162                        162        1


&lt;/PRE&gt;
&lt;P&gt;You can then work on making the logic smarter for the .U category values.&amp;nbsp; Perhaps you can also test if RESULT starts with '&amp;lt;' and take that in consideration when tying to assign a category.&amp;nbsp; &amp;nbsp;Or you could just build up a list of all of the unknown RESULTS and give them to a human to categorize.&amp;nbsp; Then use that list to make a dataset or perhaps an INFORMAT that can convert some of those in the appropriate 1 or 2 category.&lt;/P&gt;</description>
      <pubDate>Sun, 17 Apr 2022 02:20:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-Issue/m-p/808215#M318675</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-04-17T02:20:56Z</dc:date>
    </item>
    <item>
      <title>Re: Format Issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-Issue/m-p/808220#M318678</link>
      <description>Hi, Thanks for your reply. I got your point. One question this data file originally from CSV. and the one value of the variable is 1.05E+3 (3.02) which is character format. Now my question is how I convert it to numeric format and without scientific notation (E) in SAS?&lt;BR /&gt;Thanks</description>
      <pubDate>Sun, 17 Apr 2022 05:34:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-Issue/m-p/808220#M318678</guid>
      <dc:creator>ZahidHussain</dc:creator>
      <dc:date>2022-04-17T05:34:50Z</dc:date>
    </item>
    <item>
      <title>Re: Format Issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-Issue/m-p/808222#M318680</link>
      <description>&lt;P&gt;Is this a comprehensive list of input values?&lt;/P&gt;</description>
      <pubDate>Sun, 17 Apr 2022 08:02:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-Issue/m-p/808222#M318680</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-04-17T08:02:22Z</dc:date>
    </item>
    <item>
      <title>Re: Format Issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-Issue/m-p/808224#M318682</link>
      <description>Yes it is&lt;BR /&gt;</description>
      <pubDate>Sun, 17 Apr 2022 08:39:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-Issue/m-p/808224#M318682</guid>
      <dc:creator>ZahidHussain</dc:creator>
      <dc:date>2022-04-17T08:39:19Z</dc:date>
    </item>
    <item>
      <title>Re: Format Issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-Issue/m-p/808225#M318683</link>
      <description>yes it is</description>
      <pubDate>Sun, 17 Apr 2022 08:39:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-Issue/m-p/808225#M318683</guid>
      <dc:creator>ZahidHussain</dc:creator>
      <dc:date>2022-04-17T08:39:30Z</dc:date>
    </item>
    <item>
      <title>Re: Format Issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-Issue/m-p/808227#M318684</link>
      <description>&lt;P&gt;And how do the values 1, 2 and 99 map to the strings?&lt;/P&gt;</description>
      <pubDate>Sun, 17 Apr 2022 12:12:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-Issue/m-p/808227#M318684</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-04-17T12:12:45Z</dc:date>
    </item>
    <item>
      <title>Re: Format Issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-Issue/m-p/808233#M318687</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/172279"&gt;@ZahidHussain&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Hi, Thanks for your reply. I got your point. One question this data file originally from CSV. and the one value of the variable is 1.05E+3 (3.02) which is character format. Now my question is how I convert it to numeric format and without scientific notation (E) in SAS?&lt;BR /&gt;Thanks&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;And what number do you think that string means?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-SPOILER&gt;It does not look like a valid number because of the extra characters at the end.&amp;nbsp; So "1.05E+3" is just another way of writing 1050.&amp;nbsp; But the extra character make it an invalid input.&amp;nbsp; What is the meaning of the "(3.02)" at the end?&lt;/LI-SPOILER&gt;</description>
      <pubDate>Sun, 17 Apr 2022 15:31:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-Issue/m-p/808233#M318687</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-04-17T15:31:16Z</dc:date>
    </item>
    <item>
      <title>Re: Format Issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-Issue/m-p/808246#M318692</link>
      <description>I am not pretty sure . As I know the E means 2.71. The same number is in the data set. So I am confused about this</description>
      <pubDate>Sun, 17 Apr 2022 20:25:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-Issue/m-p/808246#M318692</guid>
      <dc:creator>ZahidHussain</dc:creator>
      <dc:date>2022-04-17T20:25:32Z</dc:date>
    </item>
    <item>
      <title>Re: Format Issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-Issue/m-p/808264#M318703</link>
      <description>I think you are right, That number is invalid number , so its supposed to come missing. Thanks everybody for giving me the solution</description>
      <pubDate>Mon, 18 Apr 2022 01:26:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-Issue/m-p/808264#M318703</guid>
      <dc:creator>ZahidHussain</dc:creator>
      <dc:date>2022-04-18T01:26:38Z</dc:date>
    </item>
    <item>
      <title>Re: Format Issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-Issue/m-p/808275#M318711</link>
      <description>&lt;P&gt;It would be advisable to check with the provider of the data regarding the correct treatment of the various values. If&amp;nbsp; the exponential value is unique, then setting it to missing sounds reasonable. However if you are getting a range of exponential values you might be missing some real data.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Apr 2022 03:42:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-Issue/m-p/808275#M318711</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2022-04-18T03:42:50Z</dc:date>
    </item>
    <item>
      <title>Re: Format Issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-Issue/m-p/808276#M318712</link>
      <description>I check this number in excel with trim function . It gives invalid number. Thats why I think that this is invalid input. Also this data set there is only one variable like that. Also when I run the program with best32. format it gives the missing value. Any idea of changing the format of exponential value to numeric value.&lt;BR /&gt;Thanks</description>
      <pubDate>Mon, 18 Apr 2022 04:24:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-Issue/m-p/808276#M318712</guid>
      <dc:creator>ZahidHussain</dc:creator>
      <dc:date>2022-04-18T04:24:09Z</dc:date>
    </item>
    <item>
      <title>Re: Format Issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-Issue/m-p/808277#M318713</link>
      <description>&lt;P&gt;You could try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  exponential_num = input(substr(exponential_char,1,7), 7.);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Apr 2022 04:44:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-Issue/m-p/808277#M318713</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2022-04-18T04:44:18Z</dc:date>
    </item>
    <item>
      <title>Re: Format Issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-Issue/m-p/808310#M318733</link>
      <description>Hello &lt;BR /&gt;The understanding that E is 2.71 is incorrect. It is e that is 2.7123....&lt;BR /&gt;In the present context 1.05E+3 implies 1.05 x 10^+3 and this equal 1050.&lt;BR /&gt;From what that has been mentioned, the data [reparation step is being by passed. For example "Target Not Detected" means the component that was being analyzed is either absent or in such a small quantity that it could not be detected. In is typical in certain situations to take this as zero. &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 18 Apr 2022 14:16:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-Issue/m-p/808310#M318733</guid>
      <dc:creator>Sajid01</dc:creator>
      <dc:date>2022-04-18T14:16:24Z</dc:date>
    </item>
    <item>
      <title>Re: Format Issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-Issue/m-p/808336#M318741</link>
      <description>Thanks for your reply. You cleared lot if things. But the original number is 1.05E+3(3.02) . So, at the end of this (3.02) gives invalid as I know. So, whats your suggestion. take this number as a invalid or take substr from 1 to 7 which gives the number 1050. Thanks</description>
      <pubDate>Mon, 18 Apr 2022 15:47:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-Issue/m-p/808336#M318741</guid>
      <dc:creator>ZahidHussain</dc:creator>
      <dc:date>2022-04-18T15:47:07Z</dc:date>
    </item>
    <item>
      <title>Re: Format Issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-Issue/m-p/808345#M318745</link>
      <description>I do not know the line of activity or purpose of the analysis of this data. Consult with domain specialist for guidance. This is particularly because it does not fall under 1, 2 or 99, the values you are trying to encode to.&lt;BR /&gt;</description>
      <pubDate>Mon, 18 Apr 2022 16:22:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-Issue/m-p/808345#M318745</guid>
      <dc:creator>Sajid01</dc:creator>
      <dc:date>2022-04-18T16:22:23Z</dc:date>
    </item>
    <item>
      <title>Re: Format Issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-Issue/m-p/808359#M318754</link>
      <description>Great. If that solves your question, pleas do mark the question as resolved</description>
      <pubDate>Mon, 18 Apr 2022 17:19:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-Issue/m-p/808359#M318754</guid>
      <dc:creator>Sajid01</dc:creator>
      <dc:date>2022-04-18T17:19:29Z</dc:date>
    </item>
  </channel>
</rss>

