DATA Step, Macro, Functions and more

code help

Reply
Occasional Contributor
Posts: 10

code help

Hi

I have a vital signs raw data. I have a date column and vital signs test column. there are 5 tests per subject. There is only one date is given for one test. I need to fill the same date for all the tests per subject. Need help with this logic.

 

the data looks like this:

 

date                       test

11/07/2017            

          .                   Height

          .                  DBP

           .                  SBP

                             PULSE

                             TEMP  

Thanks.

Rashmi.

Super User
Posts: 23,342

Re: code help

Posted in reply to rashmirao99
*Try using Retain to keep the variable across the rows and assigning it when new;

data want; set have; retain new_date; if not missing(date) then new_date = date; run;

rashmirao99 wrote:

Hi

I have a vital signs raw data. I have a date column and vital signs test column. there are 5 tests per subject. There is only one date is given for one test. I need to fill the same date for all the tests per subject. Need help with this logic.

 

the data looks like this:

 

date                       test

11/07/2017            

          .                   Height

          .                  DBP

           .                  SBP

                             PULSE

                             TEMP  

Thanks.

Rashmi.


 

PROC Star
Posts: 1,603

Re: code help

Posted in reply to rashmirao99

where is the subject column?

 

data want;

set have;

by subject;

retain _date;

if first.subject then call missing(_date);

if not missing(date) then _date=date;

else date=_date;

run;

Ask a Question
Discussion stats
  • 2 replies
  • 78 views
  • 0 likes
  • 3 in conversation