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

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- Base SAS Programming
- /
- how to rename zscores for a dataset with many vari...

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

02-17-2017 03:01 PM

Hello everyone,

I have a question about creating zscores for many variables in a file with tens of variables. If I do this for a few variables everything is OK, as I can rename the variables as zscores and drop the redundant names (of the original variables). However, to do this with 50 variables is tedious. I was wondering if anyone can help me automatically assign zscore names that correspond to the original variables.

Thank you very much!

Accepted Solutions

Solution

02-17-2017
03:25 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

02-17-2017 03:24 PM

Use PROC STDIZE or STANDARD to standardize the variables - which is equivalent to taking the z score if you're using the distribution of the data. You can use variable lists/shortcuts in the VAR statement to simplify the process of listing the variables.

```
proc stdize data=have out=want method=std;
var LIST_VARS_HERE;
run;
```

All Replies

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

02-17-2017 03:18 PM

Some example data, in the form of a datastep, would be helpful.

My initial guess is to use proc sql (using dictionary.columns) to write out all of the calculations and naming.

Do you have to do it for all of your numeric variables? It will also help to see the code you used to do the one example you mentioned.

Art, CEO, AnalystFinder.com

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

02-17-2017 03:23 PM

thank you so much! They are all numeric, I am using proc standard:

PROC STANDARD DATA= mydata MEAN=0 STD=1 OUT=zscoreswk;

VAR x1 x2 x3; run;

data quality.zscoreswk; set zscoreswk;

zx1=x1;

zx2=x2;

zx3=x3;

drop x1 x2 x3;

run;

I would like to be able to rename all the 50+ variables so that their new names include the original name zx1.....zx50.

Thanks! Have a nice afternoon!

Solution

02-17-2017
03:25 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

02-17-2017 03:24 PM

Use PROC STDIZE or STANDARD to standardize the variables - which is equivalent to taking the z score if you're using the distribution of the data. You can use variable lists/shortcuts in the VAR statement to simplify the process of listing the variables.

```
proc stdize data=have out=want method=std;
var LIST_VARS_HERE;
run;
```

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

02-17-2017 03:25 PM

thank you so much! best regards!

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

02-17-2017 03:26 PM

If it's a series list you can rename it as:

```
set new_data (rename = (x1-x10=zx1-zx10));
```

```
data quality.zscoreswk;
set zscoreswk (rename = (x1-x3 = zx1-zx3));
run;
```

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

02-17-2017 03:27 PM

Oh, thank you so much! This is very helpful!

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

02-17-2017 03:35 PM

sorry to bother you again, how do I do this when my variables have various labels (e.g., x1=density of streets, x2= landuse mix etc), is there an easy way to convert all variables into new variables labelled x1....x50, so i could apply the method above? Thanks again

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

02-17-2017 03:40 PM

1. Start a new question, because this is different than your original

2. Please clarify your terminology, labels are used to show a descriptive information on the variable. A variable name is different.

Are you asking how to rename variables and keep the same labels?

Or are you saying your variables aren't labelled as series x1-x10?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

02-17-2017 03:41 PM

Thanks, I will start a new question.