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;

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 1165 views
  • 0 likes
  • 1 in conversation