BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
logistics_00
Obsidian | Level 7

Hi,

 

I've written a proc univariate to calculate percentiles for a few different metrics. It works great. The problem is the output variable names are the names I've given them concatenated with the percentile amount. So pcap_br95 and so forth. I want to reference these elsewhere in my script, but I don't want to have to change the script in four places, I just want to change the percentile if necessary and run it. So I need to rename the dynamically named variables to something static. 

 

Is there anyway to create a dataset from an existing dataset like this but only by referencing the column number or position? 

 

proc univariate data= percentile_test noprint;
where br > 0;
var br pr k_starts;
;
output out=mk.br_percentile
pctlpts= 95
pctlpre = pcap_br
pctlpre = pcap_pr
pctlpre = pcap_kstarts
run;

 

I have tried creating another data set, but it requires me to name the original variables. 

 


Thanks in advance for your help.2019-11-04_15-27-21.png

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

I don't know if there's a way to do this in PROC UNIVARIATE, but in PROC SUMMARY its simple and the suffix 95 does not get appended to your output variable names.

 

proc summary data= percentile_test;
where br > 0;
var br pr k_starts;
output out=mk.br_percentile p95 = pcap_br pcap_pr pcap_kstarts;
run;
--
Paige Miller

View solution in original post

4 REPLIES 4
PaigeMiller
Diamond | Level 26

I don't know if there's a way to do this in PROC UNIVARIATE, but in PROC SUMMARY its simple and the suffix 95 does not get appended to your output variable names.

 

proc summary data= percentile_test;
where br > 0;
var br pr k_starts;
output out=mk.br_percentile p95 = pcap_br pcap_pr pcap_kstarts;
run;
--
Paige Miller
logistics_00
Obsidian | Level 7
Perfect. Turns out I was asking the wrong question, I should have started with how do I calculate these percentiles. Much appreciated!
ballardw
Super User

@logistics_00 wrote:
Perfect. Turns out I was asking the wrong question, I should have started with how do I calculate these percentiles. Much appreciated!

For what it may be worth, I tend to think of Proc Univariate as much more of an exploratory procedure to look at lots of information about the variables at one time. If I know that I want to summarize variables then going to the procedures that are more oriented to such like Proc Means, Summary or Freq seems more efficient plus the controls for such naming are more direct.

 

Reeza
Super User
Or change your output so that each variable goes to a unique line so whatever you're doing next can be done using by group processing.

sas-innovate-2024.png

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.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1320 views
  • 4 likes
  • 4 in conversation