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;

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 401 views
  • 0 likes
  • 2 in conversation