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