Arlete Ferreira
Arlete Ferreira

Reputation: 17

Creation of a table by concatenate SAS (sql)

There is this code

data &OUT_DATA.;
set &IN_DATA_ORIGINAL_RISK_SCEN.
work.RISK_SCENARIOS_FROM_CF_TO_LOAD(drop=REPORTING_DT
HORIZON_TIME_PERIOD_CNT);
run

And what I understand is that it creates table OUT_DATA by concatenating DATA_ORIGINAL_RISK_SCEN with RISK_SCENARIOS_FROM_CF_TO_LOAD. But the variables of this two tables are the same, so I'm not understanding what it does, and the values that are pretended to be on the OUTPUT table are the values of RISK_SCENARIOS_FROM_CF_TO_LOAD.

Could you give me some help? Thanks.

Upvotes: 0

Views: 36

Answers (1)

Joe
Joe

Reputation: 63424

Two datasets on the set statement appends the rows together - so if you have 1000 rows on the first one and 400 on the second one, you get 1400 rows on the final output. If they have identical variables, then the final has that set of variables; if there are other variables, then all variables that are on either dataset appear on the final, and filled with missings for the rows coming from the dataset that doesn't have that variable.

For example:

data class;
  set sashelp.class
      sashelp.class(where=(sex='M'));
run;

That appends the males to the full class dataset, so they're there twice in the final output; 29 total rows (19 from the main dataset and 10 more males), same 5 variables.

data class_cars;
  set sashelp.class
      sashelp.cars
  ;
run;

This dataset doesn't make any sense but it shows what happens when you have two datasets with different variables.

If you only see rows from one dataset, then either you have some criteria that you're removing rows based on, or you have no rows in one of the input datasets.

Upvotes: 1

Related Questions