Write and run SAS programs in your web browser

Merge data sets and Rename

Reply
Occasional Contributor
Posts: 10

Merge data sets and Rename

Hey there!

 

So I'm trying to figure out how to merge three data sets by a variable "Order_ID" into one with the name "delivery_dtl"

these are the three data sets:

data quick
slow
veryslow;

 

set orders;

 

Thanks for any help Smiley Happy

Occasional Contributor
Posts: 10

Re: Merge data sets and Rename

oh i think i got it

 

is it

 

data delivery_dtl;

 

merge quick

slow

veryslow;

 

by Order_ID;

 

run; 

Occasional Contributor
Posts: 10

Re: Merge data sets and Rename

great that worked.

 

Now how to do this:

 

Create a new variable delivery_speed in the data step; based on which data set the row / data is coming from.

 

Create a new variable report_month that will show the month and year part of the ‘delivery_date’ alone

 

I dont even understand the first task..

Regular Learner
Posts: 1

Re: Merge data sets and Rename

using the data above..

data delivery_dtl;
format delivery_date mmddyy10. ;
set delivery_dtl;
run;

Super User
Posts: 19,145

Re: Merge data sets and Rename

Question 1 - > is the observation in the merged data set from slow, quick or fast dataset?

Are you sure the question said merge?  Not combine? At any rate, if they all have the same variables this doesn't quite make sense because all the variables will be overwritten. Either use the data set option IN or INDSNAME. The documentation has examples of each option. 

 

Here's the link to the IN docs

https://support.sas.com/documentation/cdl/en/ledsoptsref/69751/HTML/default/viewer.htm#n1p1o2dsuc465...

 

Question 2 - > Look at Year/Month() functions, see the functions under Date&Time Category. 

http://support.sas.com/documentation/cdl/en/lefunctionsref/69762/HTML/default/viewer.htm#p0w6napahk6...

 

 

 

 

Ask a Question
Discussion stats
  • 4 replies
  • 177 views
  • 0 likes
  • 3 in conversation