Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- SAS Procedures
- /
- percentage but not % format

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

02-17-2012 03:26 PM

Hi, I'm calculating percentage in proc tabulate, but I need it to show up not in % (not multiplied by 100)

TABLE Transaction_Type*((AVM_Vendor_1*CI1_T)),N pctn<CI1_T all> /rts=**35**

How can I see pctn, in decimal format? eg. 0.35

Thanks

Accepted Solutions

Solution

02-19-2012
12:41 AM

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to podarum

02-19-2012 12:41 AM

You never indicated what your actual number range was and the number of decimal places. My example code wouldonly cover whole numbers ranging between 1 and 100 and all possibly 10ths between those numbers.

If your range goes from 0 to 100, each with the possibility of also including a fraction less than or greater than .1, then you would have to modify the code by adding the creation of an end variable and start the loop at 0. e.g.:

data fractions;

format label 4.3;

retain fmtname 'fraction' type 'n';

do start=0 to 100 by .1;

end=start+0.0999999999;

label=start/100;

output;

end;

run;

proc format cntlin=fractions;

run;

Let us know if that works.

All Replies

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to podarum

02-17-2012 03:54 PM

http://support.sas.com/kb/36/495.html

Search proc tabulate percent on support.sas.com

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to podarum

02-17-2012 06:58 PM

I can only think of one possibility (of course, there could easily be more). You could always just create a format to cover all possibilities. e.g. (I don't know your possibilities):

data fractions;

format label 4.3;

retain fmtname 'fraction' type 'n';

do start=1 to 100 by .1;

label=start/100;

output;

end;

run;

proc format cntlin=fractions;

run;

and then specify that format in your proc tabulate statement, e.g.:

pctn<CI1_T all>*f=fraction.

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to art297

02-18-2012 12:11 AM

Thanks Art, I'll give it a try..

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to art297

02-18-2012 10:17 PM

Hi Art, I tried running this :

data fractions;

format label 4.3;

retain fmtname 'fraction' type 'n';

do start=1 to 100 by .1;

label=start/100;

output;

end;

run;

proc format cntlin=fractions;

run;

pctn<CI1_T all>*f=fraction.

But got the same results..no errors though, but not divided by 100

Solution

02-19-2012
12:41 AM

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to podarum

02-19-2012 12:41 AM

You never indicated what your actual number range was and the number of decimal places. My example code wouldonly cover whole numbers ranging between 1 and 100 and all possibly 10ths between those numbers.

If your range goes from 0 to 100, each with the possibility of also including a fraction less than or greater than .1, then you would have to modify the code by adding the creation of an end variable and start the loop at 0. e.g.:

data fractions;

format label 4.3;

retain fmtname 'fraction' type 'n';

do start=0 to 100 by .1;

end=start+0.0999999999;

label=start/100;

output;

end;

run;

proc format cntlin=fractions;

run;

Let us know if that works.

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to art297

02-19-2012 12:49 AM

Works perfectly... once again thanks Art..