Hello,
I have a database (.txt) made up of percentage:
50
40
20
10
41
But they must not be in this form
Which format or informat would allow to have this in sas table :
0.5%
0,4%
0,2%
0.1%
0,41%
Thanks for your help
Depending upon what you actually want, here is an example of the percent format and informat on your example data:
data have; informat percent1 percent3.2; informat percent2 percent3.3; informat percent3 percent3.4; format percent1-percent3 percent6.2; input @1 percent1 @1 percent2 @1 percent3; x1=10*percent1; x2=10*percent2; x3=10*percent3; cards; 50 40 20 10 41 ;
Art, CEO, AnalystFinder.com
If you print these numbers using the PERCENT. format that is what you will get. Please be aware that it is not how you store the numbers in the table that determine how they are printed. That is what is controlled by the format definition. So SAS separates the data and the presention. As this is an important concept I advise you to read up on formats and informats.
Hope this helps,
-- Jan.
Depending upon what you actually want, here is an example of the percent format and informat on your example data:
data have; informat percent1 percent3.2; informat percent2 percent3.3; informat percent3 percent3.4; format percent1-percent3 percent6.2; input @1 percent1 @1 percent2 @1 percent3; x1=10*percent1; x2=10*percent2; x3=10*percent3; cards; 50 40 20 10 41 ;
Art, CEO, AnalystFinder.com
Are you sure this is what you want? The math is off here. Even if the number 50 refers to 50 percent, you can represent that as either 50% or 0.5. But 0.5% means something different.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.