Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Home
- /
- Programming
- /
- SAS Procedures
- /
- How do I rename proc univariate output variables?

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

🔒 This topic is **solved** and **locked**.
Need further help from the community? Please
sign in and ask a **new** question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 11-04-2019 03:28 PM
(1101 views)

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.

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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

Paige Miller

4 REPLIES 4

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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

Paige Miller

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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.

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

**If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. **

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.