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;
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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
Get started using SAS Studio to write, run and debug your SAS programs.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.