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;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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