turn on suggestions

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
- /
- General Programming
- /
- Help with rule for each set of variables

Topic Options

- 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

09-29-2013 07:16 PM

Hello Everyone,

I have a data of a 3 set of variable a1-a3 b1-b3 c1-c3.

For a1-a3, I want to calculate a ratio of value*2.0/lag(value)

For b1-b3, I want to calculate a ratio of value*1.0/lag(value)

For c1-c3, I want to calculate a ratio of value*0.5/lag(value)

I don't know how to set condition based on variable name.

Any help is very much appreciated.

Thank you,

HHC

data have;

input id a1 a2 a3 b1 b2 b3 c1 c2 c3;

datalines;

1 1 2 3 11 12 13 111 112 113

2 5 6 7 55 56 57 555 556 557

;

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

Posted in reply to hhchenfx

09-29-2013 10:26 PM

Can you please provide your desired output based on the attached sample?

This will ensure that we are interpreting what you are saying correctly.

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

Posted in reply to hhchenfx

09-29-2013 10:36 PM

Hi Scott,

My output should look like:

1 1 2 3 11 12 13 111 112 113

2 5 6 7 55 56 57 555 556 557

3 0.4 0.66

Essentially, there will be another row added to the file, and this row report the ratio.

Thank you,

HHC

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

Posted in reply to hhchenfx

09-30-2013 11:37 AM

Do you have more than 2 rows of data? Is the same ratio to be calculated between each pair of input rows? Would row 4 in output be the 3rd input row and row 5 the ratio of 2nd and 3rd input rows or rows 4 and 5 be input rows 3 and 4 with output row 6 the ratio?

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

Posted in reply to ballardw

09-30-2013 11:40 AM

I only have 2 rows data.

HHC