<?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: converting sysprocessid  to a decimal number in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/converting-sysprocessid-to-a-decimal-number/m-p/511968#M137821</link>
    <description>&lt;P&gt;Since a number in SAS is stored in 8 bytes (and not even all of those are used for the mantissa), you can't reliably convert the 16 bytes (represented by a 32-character hex string) to a number.&lt;/P&gt;
&lt;P&gt;With a little fiddling around, you can find out how the process number of the operating system is coded into sysprocessid. The process number is a longint, stored in just 32 bits/4 bytes.&lt;/P&gt;</description>
    <pubDate>Sat, 10 Nov 2018 20:32:47 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2018-11-10T20:32:47Z</dc:date>
    <item>
      <title>converting sysprocessid  to a decimal number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/converting-sysprocessid-to-a-decimal-number/m-p/511952#M137813</link>
      <description>&lt;P&gt;The macro variable &amp;amp;sysprocessid returns a 32 bit hexadecimal string.&lt;BR /&gt;Is there a way to conver it to a decimal string;&lt;/P&gt;&lt;P&gt;My code&lt;/P&gt;&lt;P&gt;data _null_;&lt;BR /&gt;temp=input(&amp;amp;sysprocessid.,best12.);&lt;BR /&gt;%put temp=;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;gives an error&lt;/P&gt;&lt;DIV class="sasSource"&gt;data _null_;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;74 temp=input(&amp;amp;sysprocessid.,best12.);&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: Line generated by the macro variable "SYSPROCESSID".&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;74 41DBADC37C0DCF424018000000000000&lt;/DIV&gt;&lt;DIV class="sasError"&gt;______________________________&lt;/DIV&gt;&lt;DIV class="sasError"&gt;22&lt;/DIV&gt;&lt;DIV class="sasError"&gt;ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;amp;, *, **, +, -, /, &amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;&amp;lt;, &amp;gt;=, AND, EQ, GE, GT, IN,&lt;/DIV&gt;&lt;DIV class="sasError"&gt;LE, LT, MAX, MIN, NE, NG, NL, NOTIN, OR, ^=, |, ||, ~=.&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;75 %put temp=;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;temp=&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;76 run;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column).&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;1:1&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: DATA statement used (Total process time):&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;real time 0.00 seconds&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;cpu time 0.00 seconds&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 10 Nov 2018 18:42:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/converting-sysprocessid-to-a-decimal-number/m-p/511952#M137813</guid>
      <dc:creator>Sajid01</dc:creator>
      <dc:date>2018-11-10T18:42:18Z</dc:date>
    </item>
    <item>
      <title>Re: converting sysprocessid  to a decimal number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/converting-sysprocessid-to-a-decimal-number/m-p/511968#M137821</link>
      <description>&lt;P&gt;Since a number in SAS is stored in 8 bytes (and not even all of those are used for the mantissa), you can't reliably convert the 16 bytes (represented by a 32-character hex string) to a number.&lt;/P&gt;
&lt;P&gt;With a little fiddling around, you can find out how the process number of the operating system is coded into sysprocessid. The process number is a longint, stored in just 32 bits/4 bytes.&lt;/P&gt;</description>
      <pubDate>Sat, 10 Nov 2018 20:32:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/converting-sysprocessid-to-a-decimal-number/m-p/511968#M137821</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-11-10T20:32:47Z</dc:date>
    </item>
    <item>
      <title>Re: converting sysprocessid  to a decimal number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/converting-sysprocessid-to-a-decimal-number/m-p/511972#M137823</link>
      <description>It is possible that the sysprocessID is unique but meaningless. In that case there is no need to decodeit into a number, to use it as a key. To display the value in a readable (but meaningless) way, use the $HEX format with a suitable width (rtfm)&lt;BR /&gt;</description>
      <pubDate>Sat, 10 Nov 2018 22:04:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/converting-sysprocessid-to-a-decimal-number/m-p/511972#M137823</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2018-11-10T22:04:10Z</dc:date>
    </item>
    <item>
      <title>Re: converting sysprocessid  to a decimal number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/converting-sysprocessid-to-a-decimal-number/m-p/511976#M137827</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/131732"&gt;@Sajid01&lt;/a&gt;:&lt;/P&gt;
&lt;P&gt;The short answer, already explained by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;, is NO.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A longer answer is two-fold:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. The W. informat you're trying to use doesn't interpret hex representation input.&lt;/P&gt;
&lt;P&gt;You'd have to either:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(a) Use the HEXw. informat as input ("&amp;amp;sysprocessid", hex32.) - but it will fail since the informat's length cannot be over 16.&lt;/P&gt;
&lt;P&gt;(b) Use the PIBw. informat as input ("&amp;amp;sysprocessid"x, pib16.) - which will fail as well since its length W cannot be over 8.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that in both cases, even if the input string were within the prescribed informat length limits, precision would be lost as soon as the result would exceed the integer precision of the SAS numeric variable (i.e. ~9e+15 under ASCII).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2.&amp;nbsp;The computation needed to convert your hex digit string into the decimal digit string is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;7441DBADC37C0DCF424018000000000000 = (7 × 16³³) + (4 × 16³²) + (4 × 16³¹) + (1 × 16³⁰) + (13 × 16²⁹) + (11 × 16²⁸) + (10 × 16²⁷) + (13 × 16²⁶) + (12 × 16²⁵) + (3 × 16²⁴) + (7 × 16²³) + (12 × 16²²) + (0 × 16²¹) + (13 × 16²⁰) + (12 × 16¹⁹) + (15 × 16¹⁸) + (4 × 16¹⁷) + (2 × 16¹⁶) + (4 × 16¹⁵) + (0 × 16¹⁴) + (1 × 16¹³) + (8 × 16¹²) + (0 × 16¹¹) + (0 × 16¹⁰) + (0 × 16⁹) + (0 × 16⁸) + (0 × 16⁷) + (0 × 16⁶) + (0 × 16⁵) + (0 × 16⁴) + (0 × 16³) + (0 × 16²) + (0 × 16¹) + (0 × 16⁰) = 39560295019911646378766846556315379040256&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As you may have guessed, software other than SAS has been used to generate the result. With a modicum of careful (and not quite so simple) programming it can be done in SAS, too, by carefully emulating the arithmetic operations one or a few digits at a time and storing the interim results in a digit string, so that in the end it would look like the result above (or by calling a non-SAS module capable of handling big arithmetic). But even if you did that, it would go back to the&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;'s point since it can be stored in a SAS numeric variable only approximately as ~3.956e+40 at a significant loss of precision and, consequently, at a loss of disambiguation between different process IDs.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Paul D.&lt;/P&gt;</description>
      <pubDate>Sat, 10 Nov 2018 22:39:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/converting-sysprocessid-to-a-decimal-number/m-p/511976#M137827</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2018-11-10T22:39:51Z</dc:date>
    </item>
    <item>
      <title>Re: converting sysprocessid  to a decimal number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/converting-sysprocessid-to-a-decimal-number/m-p/511977#M137828</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/21262"&gt;@hashman&lt;/a&gt; - congrats on a very impressive answer! And as already mentioned by others, sysprocessid is simply a key to a process and has no intrinsic meaning in itself. The decimal equivalent isn't useful for anything except maybe as an interesting intellectual challenge to calculate.&lt;/P&gt;</description>
      <pubDate>Sat, 10 Nov 2018 22:56:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/converting-sysprocessid-to-a-decimal-number/m-p/511977#M137828</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2018-11-10T22:56:31Z</dc:date>
    </item>
    <item>
      <title>Re: converting sysprocessid  to a decimal number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/converting-sysprocessid-to-a-decimal-number/m-p/512113#M137893</link>
      <description>&lt;P&gt;Since I'm now back in front of my SAS, I can give you this advice:&lt;/P&gt;
&lt;P&gt;Instead of &amp;amp;sysprocessid, use &amp;amp;sysjobid. On a UNIX system, it is the operating system's process number (I guess/hope it's the same on Windows); as it is a longint, it's easily stored as a number, and you can immediately identify your process in the process list with it.&lt;/P&gt;
&lt;P&gt;It is as unique as the sysprocessid, and more useful.&lt;/P&gt;
&lt;P&gt;Apparently, the first 16 bytes of the sysprocessid are a timestamp indicating the time when the process was started:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let timestamp=%sysfunc(inputn(%substr(&amp;amp;sysprocessid.,1,16),hex16.),e8601dt20.);
%put &amp;amp;timestamp.;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 12 Nov 2018 08:25:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/converting-sysprocessid-to-a-decimal-number/m-p/512113#M137893</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-11-12T08:25:10Z</dc:date>
    </item>
    <item>
      <title>Re: converting sysprocessid  to a decimal number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/converting-sysprocessid-to-a-decimal-number/m-p/512412#M138002</link>
      <description>&lt;P&gt;I would Like to thank all and hashman and KurtBremser for their wonderful replies.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Nov 2018 22:58:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/converting-sysprocessid-to-a-decimal-number/m-p/512412#M138002</guid>
      <dc:creator>Sajid01</dc:creator>
      <dc:date>2018-11-12T22:58:39Z</dc:date>
    </item>
  </channel>
</rss>

