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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

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