BookmarkSubscribeRSS Feed
lerdem
Quartz | Level 8

Noone has an idea?

Hi, i have a code with proc tabulate. i need to develop and add something like below:

data a;

input campus $ id $ year $ gender $  ;

datalines;

Ocala    22     2013    F

Ocala    22     2014    F

  West    35    2013    F

  West    35    2014    F

  West    35    2015    F

  West    38    2014    M

  East    48    2014    -

  East    55    2013    F

  East    55    2014    F

;

  run;

proc tabulate data=a;

class campus year gender/missing;

table (all='Total' gender ALL ), campus=''*year='' *n='';

run;

What i need is first all campus, then West campus then East campus. I don't need Ocala campus.

Other think i need is 2014 total and %tot 2014(percent).

Other think i need is 2014- 2015 and difference 2014 to 2015.

Let me show the output i am trying to achieve:

east west
2014percent20142015percent2015difference2014-2015percent difference2014-20152014percent20142015percent2015difference2014-2015percent difference2014-2015
total2%1001%1001%1002%1002%1000
gender
female1%50-%01%1001%501%500
male-%0-%000%01%501%500
none1%501%1000%00%00%00

7 REPLIES 7
lerdem
Quartz | Level 8

I clicked on assumed answered mistakenly. But didn't. Any suggestion?

ballardw
Super User

If you need difference then Proc Tabulate will not do that in the procedure. You could presummarize the data but Proc Report would be where to do column differences.

Also when discussing Proc Tabulate and percentages you need to be specific as to what the denominator and numerator should be as well as if you are looking for a PCTN or PCTSUM (and the row, column or table versions).

Use a where statement or a where dataset option to remove the Ocala records:

proc tabulate data=a;

     where campus ne 'Ocala';

...

or

proc tabulate data=a (where=(campus ne 'Ocala'));

class ...

lerdem
Quartz | Level 8

Hi ballardw, thanks for respond. I added example table. It should be like below:

east   west
2014percent20142015percent2015difference2014-2015percent difference2014-20152014percent20142015percent2015difference2014-2015percent difference2014-2015
total
gender
female
male
none

Can i do all of them with only proc report? If it is can you give me an example? I need difference and percent together like here.

ballardw
Super User

For Percent calculations you still need to specify what the denominator and numerator you are looking for may be. Provide a bit of example data and the corresponding result in the table.

lerdem
Quartz | Level 8

data a;

input campus $ id $ year $ gender $  ;

datalines;


  West 35 2013 F
  West 35 2014 F
  West 35 2015 F
  West 38 2014 M
  West 38 2015 M
  East 48 2014 -
  East 48 2015 -
  East 55 2013 F
  East 55 2014 F

;

  run;

east  west
2014percent20142015percent2015difference2014-2015percent difference2014-20152014percent20142015percent2015difference2014-2015percent difference2014-2015
total2%1001%1001%1002%1002%1000
gender
female1%50-%01%1001%501%500
male-%0-%000%01%501%500
none1%501%1000%00%00%00
ChrisNZ
Tourmaline | Level 20

This gives you the percentages you want. proc tabulate does not do differences.

data A;

input CAMPUS $ ID $ YEAR  GENDER $  ;

datalines;

  West 35 2013 F

  West 35 2014 F

  West 35 2015 F

  West 38 2014 M

  West 38 2015 M

  East 48 2014 N

  East 48 2015 N

  East 55 2013 F

  East 55 2014 F

run;

option missing=0;

proc tabulate data=A;

  where YEAR ne 2013;

  class GENDER CAMPUS YEAR;

  table all GENDER=' ',CAMPUS=' '*YEAR=' '*(N=' ' pctn<all GENDER>=' ') ;

run;

Untitled.png
 

lerdem
Quartz | Level 8

Morning ballardw. I added numbers tot he example table. Do you think it is possible to make it?

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
  • 7 replies
  • 4467 views
  • 1 like
  • 3 in conversation