DATA Step, Macro, Functions and more

Repeated set of observations for each patient

Accepted Solution Solved
Reply
New Contributor
Posts: 3
Accepted Solution

Repeated set of observations for each patient

I am a relatively new SAS user. I use SAS 9.4. I have 260 patients with their Patient IDs in sequential order from 1 to 260. I would like for each of the patient to have a set of set of repeated observations which I can use for further analysis. However, I am stuck on how to create a set of repeated observations in SAS. I do not want to manually enter the observations for each of the 260 patients.I would really appreciate suggestions. Thanks!

 

I would like the data set to look like this in the end:

Study_ID         Age_in_Days      Mean_HF

1                              2                     10

1                             15                     42

1                              70                    45

2                           2                          10

2                           15                        42

2                           70                       45

3                            2                          10

3                            15                       42

3                            70                        45


Accepted Solutions
Solution
2 weeks ago
Super User
Posts: 19,151

Re: Repeated set of observations for each patient

That's known as a cross join or cartesian product. 

 

proc sql;
create table want as
select *
from table1, table2;
quit;

View solution in original post


All Replies
Super User
Posts: 19,151

Re: Repeated set of observations for each patient

And what are you starting with? What are the rules for repeating data? Post sample data.

New Contributor
Posts: 3

Re: Repeated set of observations for each patient

Hi Reeza,

 

Below are the two variables and the set of observations that I would like to repeat for each of my patients (From 1 to 260). The first variable is Age_In_Days and the second variable is Mean_HF value. 

SAMPLE:

Age in daysMean Hf 
4575
9040.4
15031.8
22528.1
31524.6
40521.8
49519.5

I just want to create a data set that has these values repeated for each patient to look like this (I only have 3 patients here but I need it similar for all 260 patients):

14575
19040.4
115031.8
122528.1
131524.6
140521.8
149519.5
24575
29040.4
215031.8
222528.1
231524.6
240521.8
249519.5
34575
39040.4
315031.8
322528.1
331524.6
340521.8
349519.5
Solution
2 weeks ago
Super User
Posts: 19,151

Re: Repeated set of observations for each patient

That's known as a cross join or cartesian product. 

 

proc sql;
create table want as
select *
from table1, table2;
quit;
Highlighted
New Contributor
Posts: 3

Re: Repeated set of observations for each patient

Thank you, Reeza. 

☑ This topic is solved.

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

Discussion stats
  • 4 replies
  • 105 views
  • 4 likes
  • 2 in conversation