English 中文(简体)
With SAS and PROC TABULATE, how can I display a percentage for one subset of values and not ALL subsets?
原标题:
  • 时间:2009-11-24 21:45:56
  •  标签:
  • sas

If I have, say, grades (A,B,C,D,E,F), and want to display the percentage and N of kids who got an A or B out of all kids, and ONLY that info, is it possible with PROC TABULATE?

I tried using multi-label formats, but with those I have to include all the other values in the format or they just show up in the PROC TABULATE results. I m looking for something like:

Kid Group----------Total N----------A or B N----------A or B %  
Group 1            100              25                25%
Group 2            100              10                10%
最佳回答

Can t think of any way to do it with tabulate right off hand. It might be easiest to jut do it manually.

data grades;
input name $ 1-15  gender $ 16-16 grade 19-20;
datalines;
Anderson       M  75
Aziz           F  67
Bayer          M  77
Burke          F  63
Chung          M  85
Cohen          F  89
Drew           F  49
Dubos          M  41
Elliott        F  85
Hazelton       M  55
Hinton         M  85
Hung           F  98
Jacob          F  64
Janeway        F  51
Judson         F  89
Litowski       M  85
Malloy         M  79
Meyer          F  85
Nichols        M  58
Oliver         F  41
Park           F  77
Patel          M  73
Randleman      F  46
Robinson       M  64
Shien          M  55
Simonson       M  62
Smith N        M  71
Smith R        M  79
Sullivan       M  77
Swift          M  63
Wolfson        F  79
Wong           F  89
Zabriski       M  89
;
run;
proc sort data=grades;by gender;run;
data _null_;
    set grades end=last;
    by gender;
    if _n_=1 then do;
       put @1 "gender" @8 "total" @16 "A_or_B" @27 "pct";
    end;
    if first.gender then do;
         A_or_B=0;
         total=0;
    end;
    total+1;
    if grade ge 80 and grade le 100 then A_or_B+1;
    if last.gender then do;
         pct=A_or_B/total;
         put @1 gender @8 total @16 A_or_B @24 pct nlpct.;
    end;
run;
问题回答

Subset the raw dataset in PROC tabulate with where statement. e.g. where grade in ( A , B )





相关问题
SAS stack overflow: PROC SQL reading dictionary.columns

I have a program in which I am reading dictionary.columns. There is a big program with lot of code before and after the program segment in which I read dictionary.column. The program used to work ...

SAS using encrypted (PWENCODE) in EMAILPW= option

My code works fine using plain text code, but fails when I use an encrypted password filename File email emailsys = VIM emailid= "&pa_usr" emailpw= "{sasenc}39AAD23E148A9555508AC84447181DFF" ; ...

How do I change the label in a data step header?

In SAS you can do. data a(rename=(a=b) ); a = 1; run; to rename a variable in the data step data statement (or data step header as I call it). What s the syntax to change the label? I tried ...

What s the easiest way to use SQLite with SAS?

I want to investigate how to access SQLite DB from SAS. What s the easiest way of doing this? Is there a SAS product that we can license to do that? I don t want to use ODBC drivers as that seems to ...

Computing Compounded Return in SAS

I have a dataset of date(monthly), person and return(monthly). I need to calculate the compounded monthly return of the dataset from April Year t to March Year t+1 for each person. For example, ...

Exchange Server and SAS 9.1.3/9.2

has anyone successfully interacted with a microsoft exchange server in SAS 9.1.3 or 9.2? i know it can be done with SAS Ent. Guide 4.x, but i m not interested in that route if regular SAS can do it.

Logging SAS scripts

I ve been developing a lot of Java, PHP and Python. All of which offer great logging packages (Log4J, Log or logging respectively). This is a great help when debugging applications. Especially if the ...

热门标签