BookmarkSubscribeRSS Feed
rashmirao99
Fluorite | Level 6

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.

2 REPLIES 2
Reeza
Super User
*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.


 

novinosrin
Tourmaline | Level 20

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;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 653 views
  • 0 likes
  • 3 in conversation