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

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

1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

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.

View solution in original post

6 REPLIES 6
Reeza
Super User

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

Search proc tabulate percent on support.sas.com

art297
Opal | Level 21

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.


podarum
Quartz | Level 8

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

podarum
Quartz | Level 8

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

art297
Opal | Level 21

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.

podarum
Quartz | Level 8

Works perfectly... once again thanks Art..

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 824 views
  • 0 likes
  • 3 in conversation