BookmarkSubscribeRSS Feed
kernsaf
Calcite | Level 5

I am trying to merge two data sets and then create new variables from these data sets. In my library, I have two data sets (cross1 and long1) with the common variable MEDRNO. I'm trying to merge them and create two new variables (change_dilation and change_time). For these new variables, i want to take the difference between the first observation of dilation and all other observations of dilation. The same goes with change_time. However, I'm not getting any observations in my output. Any idea what I am doing wrong?

*question 1;

libname Hwk4 'C:\Users\USERABC\Desktop\Assignment 4';

run;

*question 2a;

proc sort data=hwk4.cross1;by MEDRNO;

proc sort data=hwk4.long1;by MEDRNO;

data merged;

merge hwk4.cross1 hwk4.long1;

by MEDRNO;

run;

*question 2b;

data hwk4;

if first.MEDRNO = 1 then do;

            base_dil = DILATION;

            t0 = time;

      end;

retain base_dil t0;

change_dilation = DILATION - base_dil;

change_time = time - t0;

run;

proc print;

run;

3 REPLIES 3
Reeza
Super User

What does the log say for starters.

For question 2b you dont have a set statement so you're not referring to any data set.

SKK
Calcite | Level 5 SKK
Calcite | Level 5

Some sample data would help.

Chrishi
Calcite | Level 5

For question 2b use set statement and use retain statement before set statement and try if still find problem then elobrate you issue using some dummy data.

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 3 replies
  • 759 views
  • 0 likes
  • 4 in conversation