English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

3 answers

Assume that the SAS data contains a variable called 'state' and the SAS data set called 'statedata'. Say that the variable named 'state' contains a value called 'NY'. Furthermore, let's assume that there are two variables (x and y) that you're interested to use to construct a 2-way table. SAS code would be

Method 1:

proc freq data=
statedata(where=(state='NY'));
tables x*y /chisq;
run;

proc freq data=statedata;
tables x*y /chisq;
where state in ('NY');
run;

2006-10-24 00:53:22 · answer #1 · answered by HaLa 3 · 1 0

Proc Freq

2016-11-01 00:15:34 · answer #2 · answered by ? 4 · 0 0

Technically, it's considered bad programming practice to include a where clause in a report procedure. I've seen a case (long ago) where a particular where clause used in proc freq actually gave different (and incorrect) results relative to a subsetting where clause given in a preceeding proc sort creating an output dataset for use in the proc freq. so...

proc sort data=x out=y;
by state;
where trim(left(upcase(state)))='NY'
run;

proc freq data=y;
table whatever;
quit;

Note that the parameters within the where clause attempt to 'steer' the values to prevent unexpected variation (e.g., "Ny" or " NY").

2006-10-26 17:19:18 · answer #3 · answered by hmmmmm 2 · 0 0

fedest.com, questions and answers