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;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.