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

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

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
  • 1 reply
  • 524 views
  • 1 like
  • 2 in conversation