hi , i got a question in the follow program. how could i get the reading of variables ''ssm & sspm'': eg, ssm 5.04M as numeric as 5million and 40 thousand, and eg, sspm 0.625% as numeric as 0.625 percentage.
input stdate : ddmmyy10. ssv : comma10. ssm idm sspm idssm sspidssm ;
format stdate ddmmyy10. ssv : comma10. ssm idm sspm idssm sspidssm ;
10/09/2010 588,000 5.04M 807.192M 0.625% 3.567B 0.141%
09/09/2010 2,166,000 18.506M 568.513M 3.255% 4.494B 0.412%
08/09/2010 1,512,000 12.805M 548.069M 2.336% 4.094B 0.313%
seeking a suitable informat is a popular forum question.
Although there is an informat for percentages (PERCENT.) I was not sure about a trailing M.
Previously I have responded http://support.sas.com/forums/thread.jspa?messageID=40725#40725 pointing out a technique to get SAS to try all available informats
Checking the technique with string 1000M, the best result came from informat SIZEKMG. You might not want the result from this informat :-( as it assumes the M implies megabytes because the result I got was 1048576000.
I see no alternative other than reading that input column as a string and parsing as needed .
In case you want help with that parsing business, you could do something like this:
input stdate : ddmmyy10. ssv : comma10. chssm : $20. idm chsspm : $20. idssm sspidssm ;
ssm = input( substr( chssm, 1, index( chssm, 'M' ) -1 ), 5. ) * 1000000;
Nested function calls are not always easy to read so we could break it down for readability like this:
pos = index( chssm, 'M' ); *this finds the 'M' in '5.04M';
chnbr = substr( chssm, 1, pos -1 ); *extract the numeric characters without the 'M';
ssm = input( chnbr, 5. ) * 1000000; *read the character numbers as a number and multiply by 1000000;
The approach to obtaining sspm would be similar.