BookmarkSubscribeRSS Feed
Calcite | Level 5
I have been struggling with a homework assignment for my SAS programming class. I have already done parts of it, but cannot do the end of it without figuring out one part.

The data is the following:
Each follow-up visit is represented as one record in the data set. Variables in the file are:
1. Patient id (1-50) ~ called id
3. Visit number, numbered consecutively for each subject ~ called visit
4. Time since last visit (months, with 0 at the first visit) ~ called time
5. Stage of disease (0 = early stage, and 1 = after disease progression) ~ called stage

I added a variable called tottime using this instruction:

2. Keeping data in a one row for each visit format, create a variable giving the number of months between the entry into the study for that subject and that study visit. (This will give the total number of months on study at each visit). PROC PRINT (e.g., the first 20 observations) a partial listing of the data to make sure that this new variable was created correctly

But I am now struggling with this instruction:

3. For analysis, we would like a data set with one row per subject. As part of this data set, we want a variable that gives the length of time that the subject was in the study before disease progression. For patients whose disease does not progress during the study, this would be their total time from visit 1 until the last visit. For subjects whose disease progresses during the study, we take this to be the time from visit 1 until the first visit where stage of disease is 1. (Hint: to create this variable, you should use the variable created in part B, and use the first. and last. commands. This is tricky and you may need to try this a few different ways before you find one that works. To be sure that you have it right, check your results on a few subjects who progress and a few who do not.) For each subject, only keep the id number, treatment group, follow-up time, and whether disease has progressed.

I think my professor would like us to use the proc means statement to output to a one line per subject dataset.

Any help/suggestions/nudges in the right direction would be much appreciated!

Rhodochrosite | Level 12

First, before we take this too far, make sure your professor is OK with going outside for help. I teach intro biostat and would allow it, but would also want to know about it.

Some things that I can say that would point you in the right direction.

The professor is expecting you to answer this question using the DATA step, not PROC MEANS (the hint to use FIRST. and LAST. tell you that, as they only exist in the DATA step).

To use FIRST. and LAST. require that the data be sorted (like you had to do for the first part of the problem) and the use of the BY statement in the DATA step.

You will also need to use an OUTPUT statement (or two) connected to IF statements that determine which record is needed in the final data set.

Doc Muhlbaier
Calcite | Level 5
hi can u help me out with the second question here
Calcite | Level 5
hi how did u solve the second question?
Super User

@pransh wrote:
hi how did u solve the second question?

You are resurrecting a thread that is very old, more than 12 years old. You would be better off starting your own question. The original poster did not provide any example data so no solution is actually possible, just general guidelines.


Be prepared to provide example data in the form of a data step or reference use of one of the SAS supplied data sets like SASHELP.CLASS.

Ask your questions in terms of the data you reference.



Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg



Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 4 in conversation