Hello,
I am using SAS 9.3. I have this dataset here, and I want to calculate the median of all the intervals across the same observation, for all observations.
I have attached the sample dataset (in Excel format) that I am referring to.
I want to code a new variable/column that has the calculated median interval for each observation based on any interval values that that observation has. How can I do that?
Thank you very much!
No attachement.
If you have a SAS dataset then best is to post a datastep to duplicate your data. Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.
You can add a median for selected variables similar to this:
data want; set have; MedianValue = median(var1, var2, var3, var4); run;
Replace var1, var2 etc with your list of variables you are interested in.
Or a valid variable list.
Remember to show both what you have AND what you want.
Preferably directly in the post rather than an attachment.
Two ways to calculate median - using the function as shown
or Proc Means
For your data you could simplify the code to:
data want; set have;; Median = median(of int:); run;
Art, CEO, AnalystFinder.com
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.