Re: Help - Displaying the max vaule from SAS data set



Puneet wrote:
Hi,
I am a beginner and just started using SAS 9.1 two weeks ago.
I have SAS data set which contains numeric variables and now I want to
display the max value in that data set corresponding to some particular
variable.

The quick, easy and nice solution is using SQL. If X is a variable in a dataset DS,

proc sql;
select max(X) from DS;
quit;

will print the maximum in the output frame. To put the result into a new dataset instead:

proc sql;
create table DSMAX as
select max(X) as X_MAX
from DS;
quit;

A nice general advice: If it's tricky to do using data steps, try SQL; if it's tricky to do using SQL, try data steps.

Data steps consider data a sequential list of observation, SQL considers it an unordered set of observation. Thus, they tend to be good for different things.

Einar
.



Relevant Pages

  • Re: Unique in-depth problem
    ... The back end is SQL, for the sake of sanity I broke up the dates into ... What options do I have in Perl for handling dates of this nature ... Precompute all the dates and put them in a database (file, SQL server, ... a huge data set, yet manage to retrieve and show only the interesting ...
    (comp.lang.perl.misc)
  • Re: Excel validation.
    ... The upload function will run a validation routine and I am ... would process each row in the spread sheet and call a SQL procedure to ... return a data set, the data set would hold one record if the GL# was ... I also make the use a parameter in the SQL and link it to a cell in ...
    (comp.sys.ibm.as400.misc)
  • Re: XSD schema to SQL server
    ... I think I understood what you are suggesting. ... is for each column in the data set, build the "CREATE TABLE string" and ... >> What is an easy way to save an XSD schema into SQL server database? ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Way too many Stored Procedure Parameters
    ... Start by creating a typed data set, ... Run SQL Server profiler on the database in SQL Server (filter by your ... Once you have your stored procedure, you can just drag it into VS.NET ...
    (microsoft.public.dotnet.languages.csharp)