Help using Base SAS procedures

CLASSDATA in VISIT variable

Accepted Solution Solved
Reply
Super Contributor
Posts: 301
Accepted Solution

CLASSDATA in VISIT variable

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.


Accepted Solutions
Solution
‎03-06-2013 11:59 AM
Super Contributor
Posts: 301

Re: CLASSDATA in VISIT variable

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


All Replies
Super Contributor
Posts: 301

Re: CLASSDATA in VISIT variable

sorry week5 0 2 is the last record Smiley Happy

Solution
‎03-06-2013 11:59 AM
Super Contributor
Posts: 301

Re: CLASSDATA in VISIT variable

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;

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

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