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
That's known as a cross join or cartesian product.
proc sql;
create table want as
select *
from table1, table2;
quit;
And what are you starting with? What are the rules for repeating data? Post sample data.
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 days | Mean Hf |
| 45 | 75 |
| 90 | 40.4 |
| 150 | 31.8 |
| 225 | 28.1 |
| 315 | 24.6 |
| 405 | 21.8 |
| 495 | 19.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):
| 1 | 45 | 75 |
| 1 | 90 | 40.4 |
| 1 | 150 | 31.8 |
| 1 | 225 | 28.1 |
| 1 | 315 | 24.6 |
| 1 | 405 | 21.8 |
| 1 | 495 | 19.5 |
| 2 | 45 | 75 |
| 2 | 90 | 40.4 |
| 2 | 150 | 31.8 |
| 2 | 225 | 28.1 |
| 2 | 315 | 24.6 |
| 2 | 405 | 21.8 |
| 2 | 495 | 19.5 |
| 3 | 45 | 75 |
| 3 | 90 | 40.4 |
| 3 | 150 | 31.8 |
| 3 | 225 | 28.1 |
| 3 | 315 | 24.6 |
| 3 | 405 | 21.8 |
| 3 | 495 | 19.5 |
That's known as a cross join or cartesian product.
proc sql;
create table want as
select *
from table1, table2;
quit;
Thank you, Reeza.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.
Ready to level-up your skills? Choose your own adventure.