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
- /
- SAS Procedures
- /
- scaling variable in a dataset?

- 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

12-13-2011 07:49 AM

I'd like to know how to scale a variable between 0&1 in sas. Perhaps it's possible to do with proc stdize somehow?

Accepted Solutions

Solution

12-14-2011
01:22 PM

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

12-14-2011 01:22 PM

If you want a linear transformation that maps your data to [0,1], use

proc stdize data=MyData out=StdOut method=RANGE;

var vrp;

run;

This maps min(vrp) to 0 and max(vrp) to 1. The transformation is

x --> (x - min(x))/range(x)

All Replies

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

12-13-2011 10:19 AM

It will be helpful to provide a bit more detail on what you hope to accomplish.

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

12-13-2011 02:02 PM

I simply would like to make the variable vrp scaled between 0&1, the dataset is attached above if it helps..

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

12-13-2011 03:08 PM

What are the rules for scaling between 0 and 1. How will both 116 and -118 map to the scale from 0 to 1?

You could just use the percentile, but depending on what you're doing that could make absolutely no sense.

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

12-13-2011 03:25 PM

I need the variable vrp for my time-varying regression:

**proc** **reg** data=spainbj outest=brittenjonesspain;

model Identity= MKT MKT*lag(vrp) SMB SMB*lag(vrp) HML HML*lag(vrp) MOM MOM*lag(vrp)/noint;

**run**;

this is a britten-jones regression, where betas are portfolio weights. I use the variable vrp to make the portfolio weights time-varying according to lagged value of vrp. Now I need to scale the variable vrp, in order to get the portfolio weights/betas to change in a rational way. Hope this helps..

** **

** **

** **

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

12-14-2011 01:17 AM

you want to standardize this variable to avoid the influence of scale?

proc stdize will help you. Sure there is also a function looks like stdize() to do it.

Ksharp

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

12-14-2011 12:32 PM

Yes! I tried the proc stdize but couldn't get it working. Would someone be able to give me an example on how to proceed with the code here? Thanks in advance.

Solution

12-14-2011
01:22 PM

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

12-14-2011 01:22 PM

If you want a linear transformation that maps your data to [0,1], use

proc stdize data=MyData out=StdOut method=RANGE;

var vrp;

run;

This maps min(vrp) to 0 and max(vrp) to 1. The transformation is

x --> (x - min(x))/range(x)

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

12-14-2011 02:37 PM

wow, that was easy! Thanks rick!

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

01-31-2012 05:03 AM

If I'd like to make the linear transformation between -1 and 1, how could that be done? Checked the methods from Rick's link, but none of them seem to fit this idea straight...

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

01-31-2012 05:42 AM

Run PROC STDIZE with METHOD=RANGE. That creates a variable on [0,1].

Then run a data step that sends x --> 2*x-1. The new range is [-1,1]. For example:

data StdOut;

set StdOut;

vrp = 2*vrp - 1;

run;

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

01-31-2012 03:31 PM

easy again, thanks a million rick!