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
- /
- Data Management
- /
- Forum
- /
- Matching by variables when values repeat

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

02-21-2015 09:45 PM

Hello,

I would like to make my dataset "anova_3b" look like "anova_3bb" (see attached picture). I know I can't merge by cohort/attention because there are more than one observation per combination. Could you please shed some light on how I can tranform my dataset?

Thank you,

Juan

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

Posted in reply to jcabrera

02-21-2015 11:21 PM

If I correctly understand how you are trying to collapse your data wouldn't something like the following work?:

data anova_03bb (drop=last;

set anova_03b;

last_trial=lag(trial);

last_extremity_1=lag(extremity_1);

last_extremity_0=lag(extremity_0);

if mod(_n_,2) eq 0 then do;

if missing(extremity_1) then do;

trial=last_trial;

extremity_1=last_extremity_1;

end;

else extremity_0=last_extremity_0;

output;

end;

run;

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

Posted in reply to art297

02-22-2015 02:31 PM

Arthur,

Thank you very much for looking into this. The code you gave me creates some missing observations where there should be a data value. I tried to work with it and find the reason but I could not figure it out. Below is the dataset resulting from running the code you provided me with (there should be 24 obs for Extremity_0 and 24 obs for Extremity_1) . Thanks again for looking into this.

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

Posted in reply to jcabrera

02-22-2015 02:48 PM

You would have to post your data file in order to see what you actually have. A picture of it doesn't help much.

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

Posted in reply to jcabrera

02-22-2015 03:59 PM

Actually, as I look more closely at your original example, the problem might be a lot easier. Does the following do what you want?:

data anova_03b0 (keep=extremity_0) anova_03b1 (drop=extremity_0);

set anova_03b;

if missing(extremity_1) then output anova_03b0;

else output anova_03b1;

run;

data anova_03bb;

set anova_03b1;

set anova_03b0;

run;