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
- /
- Base SAS Programming
- /
- comparing the values of 2 groups of variables in t...

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
- Permalink
- Email to a Friend
- Report Inappropriate Content

11-13-2013 08:50 AM

Hi,

I want to compare the values of 2 groups of variables in the same data set "work.have". I've saved the two groups of variables in two macro variables &gIS and &gSHOULD with proc sql. Each group has 40 variables and each variable has 60 observations (persons). The data was sorted, so the counterparty of the 1st variable in gIS is just the 1st variable in gSHOULD and so on. The aim is to do a plausibility check. If the data was right, then the values of the variables in gIS should be bigger than the ones in gSHOULD.

What i want to get is a dataset with 61 rows and 41 columns that looks like this:

| Comparison Var1 from gIS with Var1 from gSHOULD | Comparison Var2 from gIS with Var2 from gSHOULD | Comparison Var 3 from gIS with Var3 from gSHOULD |
---|---|---|---|

Person 1 | 0 | 0 | 0 |

Person 2 | 1 | 0 | 0 |

Person 3 | 0 | 0 | 1 |

The headers are a bit awkward. I think i have to name them another way. but the aim is to have a '0', where the condition gIS>gSHOULD got satisfied and 1 otherwise. So the '1' is like a warning, that sth. is wrong with the data there.

I've only worked with vectors before and since the outcoming is actually a matix, I dont know how to write my script.

I hope I made my task clear. Any help is very much appreciated!!

BR Dingdang

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

Posted in reply to Dingdang

11-13-2013 10:37 AM

I think you're coding of 0 for true and 1 for false a tad odd but if I understand your requirement something like this may be what you are asking for:

data want;

set have;

array g &gls;

array should &gShould;

array compare {40}; /* 40 since you say that's how many variables are in each of the macro variables*/

do _i_=1 to dim(g);

compare[_i_] = gls[_i_] le should[_i_];

end;

run;

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

Posted in reply to ballardw

11-13-2013 11:07 AM

hi Balladw,

thanks for your code, tried it out just now, but there is an error saying: arrayindex not in allowed range in row .. column y. and i got in log the names and the values of the variables printed out. like this:

RTF00_0080_040=ABC Bank RTF00_0100_040=2 RTF00_0120_040=1234567 RTF00_0160_040=2 RTF00_0180_040=3 RTF00_0200_040=31/12/2012 RTF00_0240_040=Max Mustermann RTF00_0260_040=1111-1111111 RTF00_0280_040=max.mustermann@musterbank.de RTF01_0060_090=4 RTF01_0100_030=10 RTF01_0110_030=4 RTF01_0120_030=7 RTF01_0130_030=8 RTF01_0140_030=8 RTF01_0150_030=7 RTF01_0160_030=7 RTF01_0170_030=4 RTF01_0180_030=4 RTF01_0190_030=4 RTF01_0100_050=2 RTF01_0110_050=10....

the variables in the data want are just the variables in gIS and gSHOULD and there are no observations.

actually i wrote sth. similar to your code and i think the problem is the dimension, or? somehow i need a matrix in the end, not a column or sth. but i am not sure if this was the problem.

BR Dingdang

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

Posted in reply to Dingdang

11-13-2013 11:28 AM

If you are working in IML then you probably need to say so and post in the IML discussion group.

Otherwise I think we need to go back a few steps to describe what is actually in your macro variables and what you wnat done.