data wf;
set sashelp.cars;
if EngineSize <=2 then excl=1;
else if Cylinders <=4 then excl=2;
else if Horsepower <=100 then excl=3;
else if MPG_City <=20 then excl=4;
else if MPG_Highway <22 then excl=5;
else if Weight <2000 then excl=6;
else if Wheelbase <100 then excl=7;
else if Length <110 then excl=8;
else
excl=99;
run;
proc format;
value exl 1=' 1 EngineSize <=2 ' 2=' 2 Cylinders <=4 '
3=' 3 Horsepower <=100 ' 4=' 4 MPG_City <=20 '
5=' 5 MPG_Highway <22 ' 6=' 6 Weight <2000 '
7=' 7 Wheelbase <100 ' 8=' 8 Length <110 ' 99='99 Pass';
run;
proc tabulate data=wf noseps missing;
format excl exl.;
class excl/preloadfmt;
tables excl all, all=''/printmiss misstext='0';
run;
proc sort data=wf ;by excl;run;
proc tabulate data=wf;
format excl exl.;
by excl;
class excl/preloadfmt;
var EngineSize Cylinders Horsepower MPG_City MPG_Highway Weight Wheelbase
Length;
tables excl, EngineSize Cylinders Horsepower MPG_City MPG_Highway Weight Wheelbase
Length , (n*f=6. min*f=6. max*f=6.) ;
run;
First result
remaining ones are by excl multiple tables but needed by excl by logic variable in one step
Example I need only engine size should be in the table not remaining variables MIN AND MAX when I run 2nd tabulate
Example I need only engine size should be in the table not remaining variables MIN AND MAX when I run 2nd tabulate
Variables, or observations? Show us what the desired table looks like, even if you have to type it in yourself and make up the N and MIN and MAX.
The result should look like the below I tried the below code but I am getting other variables too
proc means data=wf n min max ;
format excl exl. ;
/* by Exclusion_Code_Version; */
class excl
/ order=fmt ;
var
EngineSize Cylinders Horsepower MPG_City MPG_Highway Weight Wheelbase
Length
;
run;
Excl | Variable | N | Minimum | Maximum |
1 EngineSize <=2 | EngineSize | 79 | 1.3 | 2 |
2 Cylinders <=4 | Cylinders | 60 | 4 | 4 |
3 Horsepower <=100 | Horsepower | 267 | 155 | 500 |
7 Wheelbase <100 | Wheelbase | 3 | 96 | 99 |
@bobi wrote:
The result should look like the below I tried the below code but I am getting other variables too
proc means data=wf n min max ;
format excl exl. ;
/* by Exclusion_Code_Version; */
class excl
/ order=fmt ;
var
EngineSize Cylinders Horsepower MPG_City MPG_Highway Weight Wheelbase
Length
;run;
Excl Variable N Minimum Maximum 1 EngineSize <=2 EngineSize 79 1.3 2 2 Cylinders <=4 Cylinders 60 4 4 3 Horsepower <=100 Horsepower 267 155 500 7 Wheelbase <100 Wheelbase 3 96 99
I'm sorry, but this still isn't clear to me. What extra variables are you getting? Be specific. And please, as I asked, show us the table you would like to get, even if you have to make up the numbers and type it in yourself.
Please provide a narrative of what you are actually supposed to be creating. Showing code, as in your WF data set or Tabulate that does not create what you want doesn't really help a great deal. Especially when you have 3 proc tabulate calls and do not describe which one is not providing what you actually want.
The narrative is I am running a waterfall if-else conditions tagging along as exclusions and I wanted to show the waterfall report and each condition with the min and max of the variable involved in the logic
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.