Building models with SAS Enterprise Miner, SAS Factory Miner, SAS Visual Data Mining and Machine Learning or just with programming

Select data

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 7
Accepted Solution

Select data

Hi guys, I am required to produce output like the image sample from the fitness data set. May I know the solutions? The questions is like: What is the highest runtime for male and female individuals in the fitness data file? 123.pngUntitled.png


Accepted Solutions
Solution
‎06-12-2017 01:37 PM
PROC Star
Posts: 325

Re: Select data

Posted in reply to pailek1996

something like this

 title  'max runtime for female';
 proc sql;
 select max(runtime) as mxdata from sashelp.class
 where sex= 'F';
title;
 title  'max runtime for Male'; 
select max(runtime) as mxdata from sashelp.class
 where sex= 'M';
 quit;

View solution in original post


All Replies
Solution
‎06-12-2017 01:37 PM
PROC Star
Posts: 325

Re: Select data

Posted in reply to pailek1996

something like this

 title  'max runtime for female';
 proc sql;
 select max(runtime) as mxdata from sashelp.class
 where sex= 'F';
title;
 title  'max runtime for Male'; 
select max(runtime) as mxdata from sashelp.class
 where sex= 'M';
 quit;
Occasional Contributor
Posts: 7

Re: Select data

May i know, how can i get the "Obs" as the image shown.

PROC Star
Posts: 325

Re: Select data

Posted in reply to pailek1996

proc sql number;

select max(runtime) as mxdata from sashelp.class

where sex= 'F';

title;

title 'max runtime for Male';

select max(runtime) as mxdata from sashelp.class

where sex= 'M';

quit;

 

but this shows up as ROW instead of obs as heading or use SAS undocumented function monotonic() as shown below

 

proc sql ;

select monotonic() as Obs, max(runtime) as mxdata from sashelp.class

where sex= 'F';

title;

title 'max runtime for Male';

select monotonic() as Obs, max(runtime) as mxdata from sashelp.class

where sex= 'M';

quit;

Occasional Contributor
Posts: 7

Re: Select data

Thanks so much! This the solution I am looking for, much appreciated!
Trusted Advisor
Posts: 1,137

Re: Select data

[ Edited ]
Posted in reply to pailek1996

alternatively try the proc means

 

proc means data=have nway;
class sex;
var runtime;
output out=want max=max;
run;
Thanks,
Jag
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 253 views
  • 3 likes
  • 3 in conversation