DATA Step, Macro, Functions and more

Help Please Concatenate and interleaving

Reply
Occasional Contributor nrb
Occasional Contributor
Posts: 11

Help Please Concatenate and interleaving

I have attached a screenshot of the question. Please help me figure this out, i'm very lost. 


Screen Shot 2016-11-22 at 12.24.03 AM.pngScreen Shot 2016-11-22 at 12.24.03 AM.png
Respected Advisor
Posts: 4,173

Re: Help Please Concatenate and interleaving

1. read the source data using 2 data steps 

data table1;

infile datalines ..

input ...

datalines;

your data

;

run;

 

2. Concatenate

Either use Proc Append or a third data step

 

 

3. Interleaving

 

First sort your data sets by Flavor

 

Here the detailed docu with code examples of how you can combine SAS data sets

http://support.sas.com/documentation/cdl/en/lrcon/68089/HTML/default/viewer.htm#p15jvywi5avt3cn1bee8...

 

 

Trusted Advisor
Posts: 1,572

Re: Help Please Concatenate and interleaving

I'm not sure that I understand the term "cake brand" but you can check next code:

 

data Duncan;
length flavor $15;
infile datalines dlm=',' truncover;
input flavor $ height;
datalines;
Devil's food ,39
Devil's food ,36.5
White ,30.5
White ,34.5
Yellow , 37.0
Yellow , 35.0
run;

 

data Betty;
length flavor $15;
infile datalines dlm=',' truncover;
input flavor $ height;
datalines;
Devil's food ,35.5
Devil's food ,36.0
White ,35.5
White ,37.5
Yellow , 32.5
Yellow , 32.5
run;

 

data all;
set duncan
betty indsname=_dsn;
by flavor;
brand = scan(_dsn,2,'.');
run;

 

title 'Duncan & Betty results';

proc print data=all;

var brand flavor height;

run;

 

Trusted Advisor
Posts: 1,022

Re: Help Please Concatenate and interleaving

Duncan Hines and Betty Crocker are two brands of cake mix in the US.
MK
Ask a Question
Discussion stats
  • 3 replies
  • 155 views
  • 0 likes
  • 4 in conversation