BookmarkSubscribeRSS Feed
Aleksandar
Obsidian | Level 7

Hello everyone,

 

I have created certain variables that are expressed in the decimals. However, I would like to express them as percentages (for example instead of 0.1 I would like to express it as 10%).

 

What is the function that I should use?

 

These are the variables that I have created expressed in decimals:

IR_200006m_I
IR_20000_1year_I
IR_20000_2years_I
IR_20000_5years_I
IR_20000_10years_I.

 

Which code to use to express them in percentages?

 

Thank you in advance,

Aleksandar

5 REPLIES 5
PeterClemmensen
Tourmaline | Level 20

Use the Percent. Format

 

data have;
 num=0.1;
 format num percent.;
run;
Aleksandar
Obsidian | Level 7

Thank you for your reply. However, since I have many variables and many observations, it will be hard to compute every number and then to place it in the code. Isn't it possible to just select the variables and then to include function format percent.;?

PeterClemmensen
Tourmaline | Level 20

First of all. It is not a function. It is a format 🙂

 

Secondly, you can apply the Percent. Format to all variables starting with IR: like this

 

format IR_: percent.;
Kurt_Bremser
Super User

@Aleksandar wrote:

Thank you for your reply. However, since I have many variables and many observations, it will be hard to compute every number and then to place it in the code. Isn't it possible to just select the variables and then to include function format percent.;?


You don't need to re-compute anything. Just assign the format to the variables in question with the FORMAT Statement when you create them.

Kurt_Bremser
Super User

@Aleksandar wrote:

Hello everyone,

 

I have created certain variables that are expressed in the decimals. However, I would like to express them as percentages (for example instead of 0.1 I would like to express it as 10%).

 

What is the function that I should use?

 

These are the variables that I have created expressed in decimals:

IR_200006m_I
IR_20000_1year_I
IR_20000_2years_I
IR_20000_5years_I
IR_20000_10years_I.

 

Which code to use to express them in percentages?

 

Thank you in advance,

Aleksandar


And what are the contents of these variables?

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 5 replies
  • 687 views
  • 2 likes
  • 3 in conversation