BookmarkSubscribeRSS Feed
nrb
Fluorite | Level 6 nrb
Fluorite | Level 6

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
3 REPLIES 3
Patrick
Opal | Level 21

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

 

 

Shmuel
Garnet | Level 18

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;

 

mkeintz
PROC Star
Duncan Hines and Betty Crocker are two brands of cake mix in the US.
MK
--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 3 replies
  • 711 views
  • 0 likes
  • 4 in conversation