BookmarkSubscribeRSS Feed
G_I_Jeff
Obsidian | Level 7

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.

3 REPLIES 3
robby_beum
Quartz | Level 8

Hi,

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

G_I_Jeff
Obsidian | Level 7

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.

SASKiwi
PROC Star

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;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1353 views
  • 0 likes
  • 3 in conversation