Hello,
I have input data that looks like these -
Size Space Date
840K 7% 2017.183
23433K 25% 2013.034
The "K" probably is 1000 or 1024 - I take the value as 1000.
I have not seen any INFORMATS that can convert 840K to 840000 (numeric value) or 7% to 0.07 (numeric value). The date has a "." in between the year and day (in Julian format). I need to convert the date to SAS internal date. Again, I went looking at the INFORMATS available - but, I can't see any suitable ones.
I understand the coding required (for example) -
SIZEN = INPUT (SIZE. informat);
It is trying to look for a proper informat that gives me the problems.
Thank you.
TS
Yes - this is the right solution. Thank you.
data want;
infile cards firstobs=2;
format size 10. space 7.2 date date9.;
input size_string $ space :percent7. date_string :$10.;
date = input(compress(date_string,'.'),julian8.);
pos = notdigit(trim(size_string));
size = input(substr(size_string,1,pos-1),10.);
select (substr(size_string,pos,1));
when ('K') size = size * 1024;
end;
drop size_string date_string pos;
cards;
Size Space Date
840K 7% 2017.183
23433K 25% 2013.034
;
run;
You just have to "fit" the data for the proper formats. How eg the input for the JULIANw. format has to look can be taken from the documentation.
The documentation can usually be found by googling "SAS 9.4" and the keyword, or something like "SAS 9.4 informats by category".
Yes - this is the right solution. Thank you.
In future, please mark the appropriate post as the correct answer, not your reply to it.
Well, the first is simple:
sizen=input(tranwrd(size,"Z","000"),best.);
The date:
new_date=input(compress(date,"."),julian7.);
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: