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
- /
- Fill out matrix / data set according to a pattern.

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

10-22-2014 11:16 AM

Hello!

I'd like to fill out a data set by 'a group'. The rule is, that if a column has a value within a group, its value should be filled in - forward AND backward.

The start data is:

Data Have;

Input N $ X1-X4;

Datalines;

A 1 . . .

A 1 . . .

A 1 . . .

A . 2 . .

A . 2 . .

B 1 . . .

B 1 . . .

B . . 3 .

B . . . 4

B . . . 4

C . 2 . .

C . 2 . .

C . . 3 .

;

Run;

The end data should be:

A 1 2 . .

A 1 2 . .

A 1 2 . .

A 1 2 . .

A 1 2 . .

B 1 . 3 4

B 1 . 3 4

B 1 . 3 4

B 1 . 3 4

B 1 . 3 4

C . 2 3 .

C . 2 3 .

C . 2 3 .

Thanks&kind regards

Accepted Solutions

Solution

10-22-2014
11:30 AM

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

10-22-2014 11:30 AM

Data Have;

infile datalines missover;

Input N $ X1-X4;

Datalines;

A 1 . . .

A 1 . . .

A 1 . . .

A . 2 . .

A . 2 . .

B 1 . . .

B 1 . . .

B . . 3 .

B . . . 4

B . . . 4

C . 2 . .

C . 2 . .

C . . 3 .

;

Run;

proc stdize data=have reponly out=want;

var x1-x4;

by n;

run;

All Replies

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

10-22-2014 11:26 AM

Is it at all possible that for any group any of the Xi could have 2 or more non-missing values? If so, what would the rule be?

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

10-22-2014 12:20 PM

Sorry ballardw, I didn't answer your question. You're right, there are at least 2 non-missing values. I need this a an intermediate result for a 'look-up' table (and hope I will finally get to my desired result).

Solution

10-22-2014
11:30 AM

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

10-22-2014 11:30 AM

Data Have;

infile datalines missover;

Input N $ X1-X4;

Datalines;

A 1 . . .

A 1 . . .

A 1 . . .

A . 2 . .

A . 2 . .

B 1 . . .

B 1 . . .

B . . 3 .

B . . . 4

B . . . 4

C . 2 . .

C . 2 . .

C . . 3 .

;

Run;

proc stdize data=have reponly out=want;

var x1-x4;

by n;

run;

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

10-22-2014 01:24 PM

Do you know how to get rid of those warnings? Update can in this case produce the same result without being warned unnecessary.

do _n_ =

update have(obs=

by n;

end;

do _n_ =

output;

end;

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

10-22-2014 03:08 PM

Thanks **data_null_** for your input. As always, a very smart suggested solution. As far as I know warning messages are generated becasue proc stdize uses location and scale parmaters to standardize/impute missing values. These statisticas are computed whatever is available within a variable. If all of the values are missing withing a variable/group then it will not be possible to calculate these statistics so as a result these messages are appearing in the log. I am not sure how to get rid of those and looking forward to have some suggestions from the forum regarding this.

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

10-22-2014 04:08 PM

I really like "all things STDIZE" but I don't want those warnings.