DATA Step, Macro, Functions and more

Finding Min and Max values from Row

Reply
New Contributor
Posts: 2

Finding Min and Max values from Row

I have a simple prog to solve. I need to find the min and max values for a data set. Need to find min and max values of Names for all the 12 months. I am struggling to get right syntax command.

 

NameJan_15Feb_15Mar_15Apr_15May_15Jun_15Jul_15Aug_15Sep_15Oct_15Nov_15Dec_15Jan_16Feb_16
Alfred8470484261202337347626206675
Alice1518331249638244194133418257
Barbara729316950951986165271703822
Carol8256268072251914487327224875
Super User
Posts: 19,850

Re: Finding Min and Max values from Row

Posted in reply to murthyaug170

Use the min/max function in a data step.

You say 12 months but don't indicate what time period that actually is, as you have 14,months of data shown. 

Clarify your output requirements if you can't figure out the 12 month portion.  

 

Data want;
Set have;
Min_12=min(of mar_15--feb_16);

Run;
Super User
Posts: 19,850

Re: Finding Min and Max values from Row

Posted in reply to murthyaug170

Use the min/max function in a data step.

You say 12 months but don't indicate what time period that actually is, as you have 14,months of data shown. 

Clarify your output requirements if you can't figure out the 12 month portion.  

 

Data want;
Set have;
Min_12=min(of mar_15--feb_16);

Run;
New Contributor
Posts: 2

Re: Finding Min and Max values from Row

Hi, thanks for the response. What I need is a Min and Max of 14 months
only. Like Min and max of all the values for the Alfred

##- Please type your reply above this line. Simple formatting, no
attachments. -##
Super User
Posts: 19,850

Re: Finding Min and Max values from Row

Posted in reply to murthyaug170

Change the variables in the function to refer from start of the list to end.

 

The notation is 

 

function(of start_variable -- end_variable);

 

which includes all variables in between the two in your function. 

 

Or you can list out the variables.

 

min(var1, var2, var3, ... varN);

 

Documentation on variable lists can be found here:

http://support.sas.com/documentation/cdl/en/lrcon/68089/HTML/default/viewer.htm#p0wphcpsfgx6o7n1sjtq...

 

 

Super User
Posts: 5,434

Re: Finding Min and Max values from Row

Posted in reply to murthyaug170

By having data stored in a wide "excel-like" format, you make your queries syntax driven.

As opposed to storing in a long, normalised format, where you usually can act on columns values instead - a more data driven approach.

Data never sleeps
Ask a Question
Discussion stats
  • 5 replies
  • 2108 views
  • 2 likes
  • 3 in conversation