DATA Step, Macro, Functions and more

Fill in values for variable where there are blanks

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 123
Accepted Solution

Fill in values for variable where there are blanks

Here is some sample data:

 

data have;
  infile datalines;
  input ClaimNumber CLIENT $2. ID $2.;
  datalines;
. TX B
1    B
2    B
3    C
. FL C
1    K
2    D
3    B
;;
run;

And this is what I want to end up with:

 

data want;
  infile datalines;
  input ClaimNumber CLIENT $2. ID $2.;
  datalines;
. TX B
1 TX B
2 TX B
3 TX C
. FL C
1 FL K
2 FL D
3 FL B
;;
run;

The Client changes each time we hit a "." and the value of Client is there for that first line as you can see in the first sample, I just need to fill in the rest until we reach a new client and so on. Thanks.


Accepted Solutions
Solution
‎07-14-2017 02:33 PM
Super User
Posts: 19,869

Re: Fill in values for variable where there are blanks

Posted in reply to JediApprentice
data want;
set have;

retain newClient;

if not missing(Client) then newClient=Client;

run;

View solution in original post


All Replies
Solution
‎07-14-2017 02:33 PM
Super User
Posts: 19,869

Re: Fill in values for variable where there are blanks

Posted in reply to JediApprentice
data want;
set have;

retain newClient;

if not missing(Client) then newClient=Client;

run;
New Contributor
Posts: 2

Re: Fill in values for variable where there are blanks

Posted in reply to JediApprentice
Thanks
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 86 views
  • 1 like
  • 3 in conversation