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;

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Update

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 744 views
  • 0 likes
  • 2 in conversation