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.
Hi,
Can you show us an example of the data and an example of what you want the output to look like?
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.
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;
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: