<?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: Conversions on space input field in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Conversions-on-space-input-field/m-p/645719#M78545</link>
    <description>&lt;P&gt;Convert the beginning part to a number and then multiply by the right power. Are the numbers using 1024 or 1000 as the units?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input space $11.;
  size=inputn(space,cats('comma',length(space)-1,'.'));
  select (char(space,length(space)));
    when ('K') size=size*1024;
    when ('M') size=size*1024**2;
    when ('G') size=size*1024**3;
    otherwise ;
  end;
cards;
121.440K
50,956.360K
1439.280M
123.45G
1245B
;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;Obs    space                     size

 1     121.440K             124354.56
 2     50,956.360K        52179312.64
 3     1439.280M        1509194465.28
 4     123.45G        132553428172.80
 5     1245B                  1245.00&lt;/PRE&gt;</description>
    <pubDate>Wed, 06 May 2020 19:48:29 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2020-05-06T19:48:29Z</dc:date>
    <item>
      <title>Conversions on space input field</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Conversions-on-space-input-field/m-p/645603#M78540</link>
      <description>&lt;P&gt;Creating data step to input file dump. All variables are straight forward except for one containing space information. Examples of the data are:&lt;/P&gt;
&lt;P&gt;121.440K&lt;/P&gt;
&lt;P&gt;50956.360K&lt;/P&gt;
&lt;P&gt;1439.280M&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The filed is 11 bytes long with a size identifier as the last character (k=kilobytes,m=megabytes,etc.) I need to convert these values to a common denominator (numeric field representing bytes) and remove the size identifier character. My attempt so far, with what I know (SPACE variable being the one I'm referencing in my post):&lt;/P&gt;
&lt;PRE&gt;DATA FDREPORT;                    
 INFILE INFILE;                   
 INPUT @1  VOLSER   $6.           
       @8  DSNAME   $44.          
       @53 ARCYEAR  4.            
       @58 ARCJUL   3.            
       @62 SPACE    $11.          
       @74 CATALOG  $3.           
       @78 EXPYEAR  4.            
       @83 EXPJUL   3.            
       @87 RUNYEAR  4.            
       @92 RUNJUL   3.;           
 IF _N_ = 1 THEN DELETE;          
 IF INDEXC(SPACE,'K') THEN DO;    
    SPACE=TRANSLATE(SPACE,'','K');
    NUMBER=INPUT(SPACE,7.3)*1024; 
 END;                             
RUN;                              &lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;This "seems" to be working from what I've run so far. So my questions are:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Is there a better way of doing this? I realize I will have to create multiple if statements for the different size characters (k,m,g,t,p). When I run a proc contents on the pdb, it lists the NUMBER field as TYPE NUM with a length of 8?&lt;/LI&gt;
&lt;LI&gt;The last two lines of the input are summary lines that I need to skip. Is there an easy way of accomplishing this?&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 May 2020 14:21:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Conversions-on-space-input-field/m-p/645603#M78540</guid>
      <dc:creator>G_I_Jeff</dc:creator>
      <dc:date>2020-05-06T14:21:09Z</dc:date>
    </item>
    <item>
      <title>Re: Conversions on space input field</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Conversions-on-space-input-field/m-p/645616#M78541</link>
      <description>&lt;P&gt;No suggestions on how to "better" read that somewhat odd numeric format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By default SAS numeric variables are length 8, i.e. 8 bytes. That limits the number of significant digits that can be stored. You may want to check if the storage range needs to be considered for your application as this may be an issue with decimal portions of values.&lt;/P&gt;
&lt;P&gt;Somewhat operating system dependent.&lt;/P&gt;
&lt;DIV class="xis-eDocBody"&gt;
&lt;DIV id="n04ccixfia6l2pn1f8szvttqg3hm" class="xis-topic"&gt;
&lt;DIV id="p0lmcajmse7l72n1t9bscxspz77r" class="xis-topicContent"&gt;
&lt;DIV id="n0b5s6wzc8yu39n1x3nucve16mgf" class="xis-paragraph"&gt;that can be stored in SAS numeric variables.&lt;/DIV&gt;
&lt;DIV id="n1mxiw7j4pg52an1kgtp0d2lxxbo" class="xis-table"&gt;
&lt;TABLE class="tgroup"&gt;&lt;CAPTION class="xis-title"&gt;Significant Digits and Largest Integer by Length for SAS Variables under Windows&lt;/CAPTION&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="xis-horizontalLeft xis-verticalBottom"&gt;
&lt;DIV id="n174bmc1laxjzjn10y2yf5viha0h" class="xis-paraTableFirst"&gt;Length in Bytes&lt;/DIV&gt;
&lt;/TH&gt;
&lt;TH class="xis-horizontalRight xis-verticalBottom"&gt;
&lt;DIV id="p15k1g85plj9o9n11fjnqyyn1x36" class="xis-paraTableFirst"&gt;Largest Integer Represented Exactly&lt;/DIV&gt;
&lt;/TH&gt;
&lt;TH class="xis-horizontalLeft xis-verticalBottom"&gt;
&lt;DIV id="n1owae7fvk3mzjn11rof2y5aadpm" class="xis-paraTableFirst"&gt;Exponential Notation&lt;/DIV&gt;
&lt;/TH&gt;
&lt;TH class="xis-horizontalLeft xis-verticalBottom"&gt;
&lt;DIV id="p0qg6ej6xvkfryn1skdvb9wy80kw" class="xis-paraTableFirst"&gt;Significant Digits Retained&lt;/DIV&gt;
&lt;/TH&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="xis-horizontalLeft xis-verticalBottom"&gt;
&lt;DIV id="n0vdovlnw1jk4in173vq2bjsw0js" class="xis-paraTableFirst"&gt;3&lt;/DIV&gt;
&lt;/TD&gt;
&lt;TD class="xis-horizontalRight xis-verticalBottom"&gt;
&lt;DIV id="p1f3qgbma4ecofn1r77e538oqfij" class="xis-paraTableFirst"&gt;8,192&lt;/DIV&gt;
&lt;/TD&gt;
&lt;TD class="xis-horizontalLeft xis-verticalBottom"&gt;
&lt;DIV id="p059il46kyrpm8n1bom3hr5ug8yj" class="xis-paraTableFirst"&gt;2&lt;SUP&gt;13&lt;/SUP&gt;&lt;/DIV&gt;
&lt;/TD&gt;
&lt;TD class="xis-horizontalLeft xis-verticalBottom"&gt;
&lt;DIV id="n05mpz1ey131ben13hkg3rrphakm" class="xis-paraTableFirst"&gt;3&lt;/DIV&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="xis-horizontalLeft xis-verticalTop"&gt;
&lt;DIV id="n0m84znlqemra6n196i2gf1m0hxj" class="xis-paraTableFirst"&gt;4&lt;/DIV&gt;
&lt;/TD&gt;
&lt;TD class="xis-horizontalRight xis-verticalTop"&gt;
&lt;DIV id="p0ckjlpq2wmhy2n1otb42mnj7ppm" class="xis-paraTableFirst"&gt;2,097,152&lt;/DIV&gt;
&lt;/TD&gt;
&lt;TD class="xis-horizontalLeft xis-verticalTop"&gt;
&lt;DIV id="n0ffmy9pe0kz3in1nfdypk6qdo9l" class="xis-paraTableFirst"&gt;2&lt;SUP&gt;21&lt;/SUP&gt;&lt;/DIV&gt;
&lt;/TD&gt;
&lt;TD class="xis-horizontalLeft xis-verticalTop"&gt;
&lt;DIV id="n01mhhp1x1vskun1smk16tg47exa" class="xis-paraTableFirst"&gt;6&lt;/DIV&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="xis-horizontalLeft xis-verticalTop"&gt;
&lt;DIV id="p14y7xm0g118hjn1jvfebvmv65ey" class="xis-paraTableFirst"&gt;5&lt;/DIV&gt;
&lt;/TD&gt;
&lt;TD class="xis-horizontalRight xis-verticalTop"&gt;
&lt;DIV id="p0qc2t67xrxzurn1oadxxpz3f23v" class="xis-paraTableFirst"&gt;536,870,912&lt;/DIV&gt;
&lt;/TD&gt;
&lt;TD class="xis-horizontalLeft xis-verticalTop"&gt;
&lt;DIV id="n1wwgylhnt3fwon12q2te5ay0b3r" class="xis-paraTableFirst"&gt;2&lt;SUP&gt;29&lt;/SUP&gt;&lt;/DIV&gt;
&lt;/TD&gt;
&lt;TD class="xis-horizontalLeft xis-verticalTop"&gt;
&lt;DIV id="n0gv8pcgcz9ve5n1w3cgupo92ug8" class="xis-paraTableFirst"&gt;8&lt;/DIV&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="xis-horizontalLeft xis-verticalTop"&gt;
&lt;DIV id="n0yq90v8i0xm2en1g9fjtn0fd213" class="xis-paraTableFirst"&gt;6&lt;/DIV&gt;
&lt;/TD&gt;
&lt;TD class="xis-horizontalRight xis-verticalTop"&gt;
&lt;DIV id="n1xdxykf4b39cmn148yozh85c6tf" class="xis-paraTableFirst"&gt;137,438,953,472&lt;/DIV&gt;
&lt;/TD&gt;
&lt;TD class="xis-horizontalLeft xis-verticalTop"&gt;
&lt;DIV id="n0k1rpdh3hrt9zn15gtob220b772" class="xis-paraTableFirst"&gt;2&lt;SUP&gt;37&lt;/SUP&gt;&lt;/DIV&gt;
&lt;/TD&gt;
&lt;TD class="xis-horizontalLeft xis-verticalTop"&gt;
&lt;DIV id="n1c1nx3u7xrvnyn1db8r450n6ss7" class="xis-paraTableFirst"&gt;11&lt;/DIV&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="xis-horizontalLeft xis-verticalTop"&gt;
&lt;DIV id="n08tlixxzwkw99n1kszepzwfwc4y" class="xis-paraTableFirst"&gt;7&lt;/DIV&gt;
&lt;/TD&gt;
&lt;TD class="xis-horizontalRight xis-verticalTop"&gt;
&lt;DIV id="n1myxoaszxwpw1n1fn7asn52iols" class="xis-paraTableFirst"&gt;35,184,372,088,832&lt;/DIV&gt;
&lt;/TD&gt;
&lt;TD class="xis-horizontalLeft xis-verticalTop"&gt;
&lt;DIV id="n135d8ryr7mns7n189ooh3p8yuf0" class="xis-paraTableFirst"&gt;2&lt;SUP&gt;45&lt;/SUP&gt;&lt;/DIV&gt;
&lt;/TD&gt;
&lt;TD class="xis-horizontalLeft xis-verticalTop"&gt;
&lt;DIV id="n04lgwu79588van15kjvvyi33199" class="xis-paraTableFirst"&gt;13&lt;/DIV&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="xis-horizontalLeft xis-verticalTop"&gt;
&lt;DIV id="n03khpkdiu3jeyn101034amjy2c2" class="xis-paraTableFirst"&gt;8&lt;/DIV&gt;
&lt;/TD&gt;
&lt;TD class="xis-horizontalRight xis-verticalTop"&gt;
&lt;DIV id="p17thjcv8btyc4n1l86zaaznq4j4" class="xis-paraTableFirst"&gt;9,007,199,254,740,992&lt;/DIV&gt;
&lt;/TD&gt;
&lt;TD class="xis-horizontalLeft xis-verticalTop"&gt;
&lt;DIV id="n1ddqo0zh75y0fn1tlrwh6sr2mr5" class="xis-paraTableFirst"&gt;2&lt;SUP&gt;53&lt;/SUP&gt;&lt;/DIV&gt;
&lt;/TD&gt;
&lt;TD class="xis-horizontalLeft xis-verticalTop"&gt;
&lt;DIV id="n1t4vquuqxntk7n1mumgbm5n651h" class="xis-paraTableFirst"&gt;15&lt;/DIV&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;DIV id="p0sig88cz4j2qwn1i643zxft1xuf" class="xis-paragraph"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there any specific way from the data that your "summary" is indicated in the file? For instance if the "summary" line starts with the word "Total" you can check the input buffer with something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;input @;
If _infile_ =: 'Total' then input; /* this would be the summary line*/
else do;
   input &amp;lt;your existing input statement&amp;gt;
   &amp;lt;other code executed for "valid" data&amp;gt;
   output; /*this output means only data from valid records gets output to the data set*/
end;&lt;/PRE&gt;
&lt;P&gt;The input @ holds the input buffer. The _infile_ is a temporary variables SAS creates that holds the entire current input line of data. So you can examine it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may want to provide an actual example of what your last 3 or 4 rows of the infile looks like. Copy them using a plain text editor and paste the copied text into code box opened on the forum using the &amp;lt;/&amp;gt; icon to preserve formatting of the text.&lt;/P&gt;</description>
      <pubDate>Wed, 06 May 2020 14:46:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Conversions-on-space-input-field/m-p/645616#M78541</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-05-06T14:46:21Z</dc:date>
    </item>
    <item>
      <title>Re: Conversions on space input field</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Conversions-on-space-input-field/m-p/645715#M78544</link>
      <description>&lt;P&gt;It would take some time for me to get this right, but could you do something like:&lt;/P&gt;
&lt;P&gt;Read in the values as character;&lt;/P&gt;
&lt;P&gt;Use REVERSE to get the alphabetic character at the front&lt;/P&gt;
&lt;P&gt;Use SUBSTR to get the alphabetic character in one variable (var_1)&lt;/P&gt;
&lt;P&gt;Use SUBSTR with no length argument to get the numeric characters in another variable (var_2)&lt;/P&gt;
&lt;P&gt;Use REVERSE on var_2 to restore the original ordering&lt;/P&gt;
&lt;P&gt;Use INPUT (var_2, best.) to get the mantissa into numeric format (var_3)&lt;/P&gt;
&lt;P&gt;Define var_4 based on var_1 (k=1024, etc.&lt;/P&gt;
&lt;P&gt;Multiply var_3 by var_4 to get var_5&lt;/P&gt;
&lt;P&gt;Add them all up.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Don't know if this would also solve the issue of what is in the last two lines, but you could probably write some easy trapping code involving var_1 and var_2 to eliminate those records.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SteveDenham&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 May 2020 19:27:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Conversions-on-space-input-field/m-p/645715#M78544</guid>
      <dc:creator>SteveDenham</dc:creator>
      <dc:date>2020-05-06T19:27:05Z</dc:date>
    </item>
    <item>
      <title>Re: Conversions on space input field</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Conversions-on-space-input-field/m-p/645719#M78545</link>
      <description>&lt;P&gt;Convert the beginning part to a number and then multiply by the right power. Are the numbers using 1024 or 1000 as the units?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input space $11.;
  size=inputn(space,cats('comma',length(space)-1,'.'));
  select (char(space,length(space)));
    when ('K') size=size*1024;
    when ('M') size=size*1024**2;
    when ('G') size=size*1024**3;
    otherwise ;
  end;
cards;
121.440K
50,956.360K
1439.280M
123.45G
1245B
;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;Obs    space                     size

 1     121.440K             124354.56
 2     50,956.360K        52179312.64
 3     1439.280M        1509194465.28
 4     123.45G        132553428172.80
 5     1245B                  1245.00&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 May 2020 19:48:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Conversions-on-space-input-field/m-p/645719#M78545</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-05-06T19:48:29Z</dc:date>
    </item>
    <item>
      <title>Re: Conversions on space input field</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Conversions-on-space-input-field/m-p/645834#M78546</link>
      <description>This is a much better method than my flipping things back and forth to extract the alphabetic part of the input string.&lt;BR /&gt;&lt;BR /&gt;SteveDenham</description>
      <pubDate>Thu, 07 May 2020 12:02:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Conversions-on-space-input-field/m-p/645834#M78546</guid>
      <dc:creator>SteveDenham</dc:creator>
      <dc:date>2020-05-07T12:02:59Z</dc:date>
    </item>
    <item>
      <title>Re: Conversions on space input field</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Conversions-on-space-input-field/m-p/645844#M78547</link>
      <description>&lt;P&gt;Tom, these are mainframe storage numbers so I'm pretty sure they will by multiplied by 1024 due to binary storage fields. Thank you for your input and I believe this will help me along nicely.... if I can interpret it!&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":beaming_face_with_smiling_eyes:"&gt;😁&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 07 May 2020 12:13:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Conversions-on-space-input-field/m-p/645844#M78547</guid>
      <dc:creator>G_I_Jeff</dc:creator>
      <dc:date>2020-05-07T12:13:26Z</dc:date>
    </item>
    <item>
      <title>Re: Conversions on space input field</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Conversions-on-space-input-field/m-p/645932#M78548</link>
      <description>&lt;P&gt;Tom,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How would you suggest me getting a variable with YYYY with anther variable JJJ (julian date) into one recognized date field?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Var1 4.,&amp;nbsp; /*YYYY*/&lt;/P&gt;
&lt;P&gt;Var2 3.&amp;nbsp; /*JJJ*/&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 May 2020 15:52:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Conversions-on-space-input-field/m-p/645932#M78548</guid>
      <dc:creator>G_I_Jeff</dc:creator>
      <dc:date>2020-05-07T15:52:39Z</dc:date>
    </item>
  </channel>
</rss>

