SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
draroda
Fluorite | Level 6

Hi Team,

 

I have one dataset where values for datasets to be merged and out dataset name mentioned.

 

I don't want to write proc sql repeatedly and want to achieve this task with help of call execute or macro.

 

Can you please help on same ?

 

Below is the dataset .

 

data temp;
input ds1 $ 1-4 ds2 $6-9 out $ 10-14;
datalines;
DEMO AECM AE
DEMO CMAE CM
DEMO MHCM CM
TEMP OTHR TMP 
TEMP EX12 EXR
;
1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

Use call execute():

data _null_;
set temp end=eof;
if _n_ = 1 then call execute('proc sql;');
call execute('create table ' !! out !! ' as select a.var1,b.var2 from ' !! ds1 !! ' as a, ' !! ds2 !! ' as b where a.xxx = b.xxx;');
if eof then call execute('quit;');
run;

View solution in original post

2 REPLIES 2
andreas_lds
Jade | Level 19

What have you tried so far? Do you want to merge without BY-statement? If not, you have to add the by-variable(s) to your temp-dataset.

 

 

Kurt_Bremser
Super User

Use call execute():

data _null_;
set temp end=eof;
if _n_ = 1 then call execute('proc sql;');
call execute('create table ' !! out !! ' as select a.var1,b.var2 from ' !! ds1 !! ' as a, ' !! ds2 !! ' as b where a.xxx = b.xxx;');
if eof then call execute('quit;');
run;

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 2094 views
  • 0 likes
  • 3 in conversation