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

I have a dataset that looks like this:

 

subjid       week      seqday   score

1                 1             1             4

1                 1             2             5

1                 1             3             0

1                 1             4             1

1                 1             5             .

1                 1             6             3

1                 1             7             2

1                 8             50           1

1                 8             51           0

1                 8             52           0

1                12            78           1

1                12            79           2

1                16            106         3

1                16            107         .

 

I basically want to keep data of every 2nd day of the week. So that corresponds to numbers 2, 51, 79, 107 in variable seqday so it looks like this:

 

subjid       week      seqday   score

1                 1             2             5

1                 8             51           0

1                12            79           2

1                16            107         .

 

 

And then I would like to transpose the data so that it reads

subjid      week1score        week8score      week12score    week16score

1                 5                      0                    2                   .

 

I'm thinking the code should be (but didnt work):

data new;

set old;

if seqday = 2 or 51 or 79 or 107;

run;

 

proc transpose data=new out=newA

      by subjid;

      var score;

run;

1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

You were close but, when coding in SAS, you have to use the SAS language. e.g.:

 

data new;
  set old;
  if seqday in (2,51,79,107);
run;

proc transpose data=new out=newA (drop=_:) prefix=week suffix=score;
  by subjid;
  var score;
  id week;
run;

Art, CEO, AnalystFinder.com

 

View solution in original post

1 REPLY 1
art297
Opal | Level 21

You were close but, when coding in SAS, you have to use the SAS language. e.g.:

 

data new;
  set old;
  if seqday in (2,51,79,107);
run;

proc transpose data=new out=newA (drop=_:) prefix=week suffix=score;
  by subjid;
  var score;
  id week;
run;

Art, CEO, AnalystFinder.com

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 583 views
  • 1 like
  • 2 in conversation