- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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..
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??
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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%
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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:
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
Jag
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hey
Thanks for your effort. The code is now running smooth. Output is coming as expected.
Thanks,
Roy