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

Hi everyone, I have these two datasets:

data have1;

input week $ ord count;

datalines;

week1 1 2

week2 1 3

week3 1 4

week4 1 3

week5 1 5

;

run;

data have2;

input week $ ord count;

datalines;

week1 2 1

week3 2 3

week4 2 4

;

run;

I want to obtain the final dataset (you can see, I want to keep the same structure in ord=2 that I have for ord=1):

week1 2 1

week2 3 1

week3 4 1

week4 3 1

week5 5 1

week1 1 2

week2 0 2

week3 3 2

week4 4 2

week5

I think CLASSDATA would do this job, but I do not remember How to apply to this particular problem.

Thank you.

V.

1 ACCEPTED SOLUTION

Accepted Solutions
michtka
Fluorite | Level 6

I just remembered it from data_null in other conversation Smiley Happy

*creating classdata;

data classdata;

  set have1 (keep=week);

run;

*creating my final dataset;

data have3;

  set have1 have2;

by ord;

run;

*data_null code structure from other problem;

proc summary nway data=have3 classdata=classdata order=data;

   by ord;

   class week;

   output out=want(drop=_freq_ _type_) idgroup(out(count)=);

   run;

View solution in original post

2 REPLIES 2
michtka
Fluorite | Level 6

sorry week5 0 2 is the last record Smiley Happy

michtka
Fluorite | Level 6

I just remembered it from data_null in other conversation Smiley Happy

*creating classdata;

data classdata;

  set have1 (keep=week);

run;

*creating my final dataset;

data have3;

  set have1 have2;

by ord;

run;

*data_null code structure from other problem;

proc summary nway data=have3 classdata=classdata order=data;

   by ord;

   class week;

   output out=want(drop=_freq_ _type_) idgroup(out(count)=);

   run;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 2 replies
  • 1101 views
  • 0 likes
  • 1 in conversation