BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jomag
Obsidian | Level 7

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

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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

4 REPLIES 4
Reeza
Super User

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

jomag
Obsidian | Level 7

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
Reeza
Super User

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

 

proc sql;
create table want as
select *
from table1, table2;
quit;
jomag
Obsidian | Level 7

Thank you, Reeza. 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 4 replies
  • 1309 views
  • 4 likes
  • 2 in conversation