BookmarkSubscribeRSS Feed
bobi
Fluorite | Level 6

 

 

 

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 

bobi_0-1649266576558.png

remaining ones are by excl multiple tables but needed by excl by logic variable in one step 

 

bobi_1-1649266637055.png

Example I need only engine size should be in the table not remaining variables MIN AND MAX when I run 2nd tabulate 

 

 

 

5 REPLIES 5
PaigeMiller
Diamond | Level 26

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.

--
Paige Miller
bobi
Fluorite | Level 6

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;

 

ExclVariableNMinimumMaximum
 1 EngineSize <=2EngineSize791.32
 2 Cylinders <=4Cylinders6044
3 Horsepower <=100 Horsepower267155500
7 Wheelbase <100Wheelbase39699

 

PaigeMiller
Diamond | Level 26

@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.

--
Paige Miller
ballardw
Super User

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.

bobi
Fluorite | Level 6

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

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

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.

Discussion stats
  • 5 replies
  • 684 views
  • 0 likes
  • 3 in conversation