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.
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.
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.