BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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.
-------------------------------------------------------------
data projects;
input stdate : ddmmyy10. ssv : comma10. ssm idm sspm idssm sspidssm ;
format stdate ddmmyy10. ssv : comma10. ssm idm sspm idssm sspidssm ;
datalines;
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%
;

proc print data=projects;
run;
4 REPLIES 4
Peter_C
Rhodochrosite | Level 12
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 .

good luck
peterC
WaltSmith
Fluorite | Level 6
In case you want help with that parsing business, you could do something like this:
[pre]
data projects;
input stdate : ddmmyy10. ssv : comma10. chssm : $20. idm chsspm : $20. idssm sspidssm ;
ssm = input( substr( chssm, 1, index( chssm, 'M' ) -1 ), 5. ) * 1000000;
run;
[/pre]
Nested function calls are not always easy to read so we could break it down for readability like this:
[pre]
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;
[/pre]
The approach to obtaining sspm would be similar.
deleted_user
Not applicable
thanks waltsmith, there a lot of beautiful people live around. god bless
deleted_user
Not applicable
thanks peter c. keep the good things inside u

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
  • 4 replies
  • 613 views
  • 0 likes
  • 3 in conversation