Desktop productivity for business analysts and programmers

DATA STEP

Reply
Contributor
Posts: 25

DATA STEP

Hello Team,

 

I am just wondering what below step actually does

 

data strat.rep_raised_resolved;
set strat.rep_raised_resolved strat.rep_raised_resolvedtotal;
if portfolio = '' then portfolio="TOTAL";
run;

 

Is it merge or union or full outer join or something else ? Can we relate it with any PROC SQL ?

 

Please advice us here

 

Thanks In Advance

Super User
Super User
Posts: 7,725

Re: DATA STEP

This isn't really a question.  You may want to learn SAS so you understand some of these basics.

For your code, it is doing two things:

1) it is setting the three datasets: strat.rep_raised_resolved strat.rep_raised_resolvedtotal, underneath each other starting from the left.  A bit like a union all statement in SQL, except that set expands the final dataset to incorperate all the variables found across the three datasets.

2) An if logic block decides if the variable portfolio is empty ('') and if so populates it with the string "TOTAL".

 

Frequent Contributor
Posts: 144

Re: DATA STEP

Hi,

It is a "union all". The result dataset will contain all observation of both datasets.
Super User
Super User
Posts: 7,725

Re: DATA STEP

Just to add, its not quite a union all (unless by happenstance all datasets have the same structure).  Union all will fail if any of the datasets have more or less columns, and do implcit length alterations if needed.  Set will fail if datatypes are different for existing columns.

Super Contributor
Posts: 308

Re: DATA STEP

Hello,

 

Just to add - union will also fail if datatypes are different for the same column

Ask a Question
Discussion stats
  • 4 replies
  • 318 views
  • 1 like
  • 4 in conversation