Desktop productivity for business analysts and programmers

To create percent sign behind any numeric value

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 8
Accepted Solution

To create percent sign behind any numeric value

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


Accepted Solutions
Solution
‎08-05-2017 10:30 AM
PROC Star
Posts: 1,167

Re: To create percent sign behind any numeric value

Posted in reply to Sourav_sas

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


All Replies
Occasional Contributor
Posts: 8

Re: To create percent sign behind any numeric value

Posted in reply to Sourav_sas
Anyone able to answer this. Please go ahead. I need this asap. I am working on this...
PROC Star
Posts: 1,167

Re: To create percent sign behind any numeric value

Posted in reply to Sourav_sas

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;

Occasional Contributor
Posts: 8

Re: To create percent sign behind any numeric value

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??

 

 

PROC Star
Posts: 1,167

Re: To create percent sign behind any numeric value

Posted in reply to Sourav_sas

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;

Occasional Contributor
Posts: 8

Re: To create percent sign behind any numeric value

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

 

PROC Star
Posts: 1,167

Re: To create percent sign behind any numeric value

Posted in reply to Sourav_sas

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

Occasional Contributor
Posts: 8

Re: To create percent sign behind any numeric value

[ Edited ]

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.

Solution
‎08-05-2017 10:30 AM
PROC Star
Posts: 1,167

Re: To create percent sign behind any numeric value

Posted in reply to Sourav_sas

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

 

Occasional Contributor
Posts: 8

Re: To create percent sign behind any numeric value

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

 

Trusted Advisor
Posts: 1,137

Re: To create percent sign behind any numeric value

Posted in reply to Sourav_sas

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
Occasional Contributor
Posts: 8

Re: To create percent sign behind any numeric value

Posted in reply to Jagadishkatam

Hey

 

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

 

Thanks,

Roy

 

 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

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