Help using Base SAS procedures

Numeric data informat with character data (kilobytes= 2601k)

Reply
Frequent Contributor
Posts: 75

Numeric data informat with character data (kilobytes= 2601k)

I've tried searching for the answer throughout the forums and Google but can't seem to search correctly, not sure how to ask this.

I have an input file I need to read through and pull storage numbers off of. The field is 6 bytes in length and is represented in bytes. But once the numbers climb above a meg they begin to represent themselves as 2601k, as an example. My question is, how can I input this field as a numeric when a character field defines the value?

I've read through all the standard SAS informat pages for numeric data and haven't found anything that will fit my situation.

Contributor
Posts: 73

Re: Numeric data informat with character data (kilobytes= 2601k)

Hi,

Can you show us an example of the data and an example of what you want the output to look like?

Frequent Contributor
Posts: 75

Re: Numeric data informat with character data (kilobytes= 2601k)

Posted in reply to robby_beum

Sure, the field is 6 bytes long and here is an excerpt:

477273

477273

475727

475727

475727

475727

475727

1001k

1001k

1001k

998450

998450

998450

998450

998450

998450

998450

998450

998450

I really don't care what output looks like, as long as it is in "a" correct format. I need to summarize this data and the input format needs to be big enough to hold petabyte/terabyte size fields? I'm not sure I am stating that correctly.

Super User
Posts: 3,260

Re: Numeric data informat with character data (kilobytes= 2601k)

Something like this may do the trick. I am assuming that K represents thousands so that means any number with a K can only be in whole thousands. If the K represents computer storage bytes then change the "1000" to "1024"

data try;

  input column $6.;

  if indexc(column,'k') then do;

    column = translate(column,'', 'k');

    number = input(column, 6.) * 1000;

  end;

  else number = input(column, 6.);

  put column = number = ;

cards;

477273

1001k

;

run;

Ask a Question
Discussion stats
  • 3 replies
  • 163 views
  • 0 likes
  • 3 in conversation