BookmarkSubscribeRSS Feed
genius99
Calcite | Level 5

how can I merge the datasets keeping both Rate_1M_CD fields as different fields by renaming the my_citimon version as MON_RATE

data work.my_citiday;
  set sashelp.citiday;
  if '01-JAN-88'd <= date <= '31-OCT-88'd and day(date)='01';
  DowComposite=snydjcm;
  Rate_1M_CD = dcd1m;
  keep date DowComposite Rate_1M_CD;
run;

data work.my_citimon;
  set sashelp.citimon;
  if '01-MAR-88'd <= date <= '31-DEC-88'd;
  format date DATE9.;
  Rate_1M_CD = FSPCAP/100;
  Common_Stock_Price_Index = FSPCON;
  keep date Rate_1M_CD Common_Stock_Price_Index;
run;
1 REPLY 1
Reeza
Super User

One option is to rename the variable in the data step shown. 

Replace the items in red, with the items in blue. 

 

data work.my_citimon;
  set sashelp.citimon;
  if '01-MAR-88'd <= date <= '31-DEC-88'd;
  format date DATE9.;
  Rate_1M_CD = FSPCAP/100;
MON_RATE = FSPCAP/100; Common_Stock_Price_Index = FSPCON; keep date Rate_1M_CD MON_RATE Common_Stock_Price_Index; run;

Another is to use the data set options RENAME to change the name. 

 

data want;
merge my_citiday mycitimon (rename = (rate_1m_cd = mon_rate));

@genius99 wrote:

how can I merge the datasets keeping both Rate_1M_CD fields as different fields by renaming the my_citimon version as MON_RATE

data work.my_citiday;
  set sashelp.citiday;
  if '01-JAN-88'd <= date <= '31-OCT-88'd and day(date)='01';
  DowComposite=snydjcm;
  Rate_1M_CD = dcd1m;
  keep date DowComposite Rate_1M_CD;
run;

data work.my_citimon;
  set sashelp.citimon;
  if '01-MAR-88'd <= date <= '31-DEC-88'd;
  format date DATE9.;
  Rate_1M_CD = FSPCAP/100;
  Common_Stock_Price_Index = FSPCON;
  keep date Rate_1M_CD Common_Stock_Price_Index;
run;

 

Develop Code with SAS Studio

Get started using SAS Studio to write, run and debug your SAS programs.

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
  • 1 reply
  • 911 views
  • 0 likes
  • 2 in conversation