SAS Procedures

Help using Base SAS procedures
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-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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