BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Sourav_sas
Quartz | Level 8

I have a table. There I have a numeric column name abc. I have numeric value there as 100.0000000. The value showiing as this. I need to show this as 100.0000000%. I am not able to do that using percentagen. method. Anyone can help me to show that format. Any method welcome, like data step or SQL. Please solve the issue.

 

Thanks & Regards

Sourav Roy

1 ACCEPTED SOLUTION

Accepted Solutions
TomKari
Onyx | Level 15

So, lets assume you have a SAS dataset named "Have", that has a field "ABC" with the value of 100. This code creates it for my purposes, but you don't need it. When I run the code, my value of "100" just looks like a normal number.

 

data have;

abc = 100;

output;

run;

 

First, you create the format using PROC FORMAT:

 

proc format;

picture SPf low-high='999.9999999%' (mult=10000000);

run;

 

Then you use PROC DATASETS to attach the format to the variable:

 

proc datasets lib=work nolist;

modify have;

format abc SPf.;

quit;

 

And from then on, whenever you open the dataset in the viewer, you should see it with the format.

 

Tom

 

View solution in original post

11 REPLIES 11
Sourav_sas
Quartz | Level 8
Anyone able to answer this. Please go ahead. I need this asap. I am working on this...
TomKari
Onyx | Level 15

What happens when you run this? It works for me.

 

Tom

 

data have;

abc = 1;

format abc percent14.7;

output;

proc print data=have;

run;

Sourav_sas
Quartz | Level 8
Data have;                                                                                                                              
abc = 100;                                                                                                                              
format abc 11.10;                                                                                                                       
output;                                                                                                                                 
proc print data= have;                                                                                                                  
run;                                                                                                                                    

Hi Tomkari

 

Thanks for your effort. But the issue is like in my dataset is like the above one.sas issue.jpg.

my table output is coming as above one.

I need this one will show as 100.0000000% in the column abc.

How can I do that??

 

 

TomKari
Onyx | Level 15

Well, I have to admit my advice is to divide your value by 100, so that you're using percentages in the standard fashion. Doing what you're doing will confuse the heck out of everybody.

 

However, if that's what you need to do, give this a try:

 

proc format;

picture SPf low-high='999.9999999%' (mult=10000000);

run;

data have;

abc = 100;

format abc SPf.;

output;

proc print data=have;

run;

Sourav_sas
Quartz | Level 8

The proc format portion is really helping. But i was given a task. There I already have a table where the column value is 100.0000000. Here please apply the proc format on 100.0000000. I am not able to do on this decimal figure.

I hope I am able to make u understand.

 

I am refering the original table.

 

Please to convert this value as 100.0000000%table.jpg

 

TomKari
Onyx | Level 15

When I run this code:

 

proc format;

picture SPf low-high='999.9999999%' (mult=10000000);

run;

data have;

abc = 100;

format abc SPf.;

output;

run;

 

This is the result I see:

 

Screengrab.png

Sourav_sas
Quartz | Level 8

Hi

 

Then what would be my code can u suggest me

 

as i can not run

data have;

abc = 100; format abc SPf.;

output;

run;

 

this part.

 

As I already have the dataset where the column showing as 100.000000. I have the task to show this as 100.0000000%.

 

So what I need to do in coding?

 

I can use the part

proc format;

picture SPf low-high='999.9999999%' (mult=10000000);

run;

 

 

Say I have column a in the dataset X,

where the column is as 100.0000000.

I need to convert it as 100.0000000%. So what would be code.

TomKari
Onyx | Level 15

So, lets assume you have a SAS dataset named "Have", that has a field "ABC" with the value of 100. This code creates it for my purposes, but you don't need it. When I run the code, my value of "100" just looks like a normal number.

 

data have;

abc = 100;

output;

run;

 

First, you create the format using PROC FORMAT:

 

proc format;

picture SPf low-high='999.9999999%' (mult=10000000);

run;

 

Then you use PROC DATASETS to attach the format to the variable:

 

proc datasets lib=work nolist;

modify have;

format abc SPf.;

quit;

 

And from then on, whenever you open the dataset in the viewer, you should see it with the format.

 

Tom

 

Sourav_sas
Quartz | Level 8

Thanks @TomKari 

 

You made my day today. For a long time I was stucking with this silly code. 

Now the output coming as expected. 

 

Thanks a lot.

 

I will be looking for more help from you.

It's been a great work with you.

 

Thanks and Regards,

Roy

 

Jagadishkatam
Amethyst | Level 16

as @TomKari already mentioned you could try the same format as below

 

proc format; 
picture SPf 
low-high='999.9999999%' (mult=10000000); 
run; 

data have;
x=100.0000000;
format x SPf.;
put x=;
run;
Thanks,
Jag
Sourav_sas
Quartz | Level 8

Hey

 

Thanks for your effort. The code is now running smooth. Output is coming as expected. 

 

Thanks,

Roy

 

 

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 11 replies
  • 6927 views
  • 3 likes
  • 3 in conversation