Hello,
I would like to rename the following variable in Proc SQL although I know it could be done in SAS data steps. But I would like to use in PROC SQL, how? Thanks.
data dataout.rename;
set dataout.test;
rename HAVARTH3=AR _PRACE=RACE _AGEG5YR=AGE _INCOMG=INCOME _HCVU651=INSURANCE _BMI5CAT=BMI
LMTJOIN3=LMTJOIN DRNKANY5=DRNKANY DIABETE3=DIABETE _SMOKER3=SMOKER;
run;
PROC SQL;
CREATE TABLE dataout.rename AS
SELECT HAVARTH3 AS AR
,_PRACE AS RACE
,_AGEG5YR AS AGE
,_INCOMG AS INCOME
,_HCVU651 AS INSURANCE
,_BMI5CAT AS BMI
,LMTJOIN3 AS LMTJOIN
,DRNKANY5 AS DRNKANY
,DIABETE3 AS DIABETE
,_SMOKER3 AS SMOKER
FROM dataout.test;
;QUIT;
PROC SQL;
CREATE TABLE dataout.rename AS
SELECT HAVARTH3 AS AR
,_PRACE AS RACE
,_AGEG5YR AS AGE
,_INCOMG AS INCOME
,_HCVU651 AS INSURANCE
,_BMI5CAT AS BMI
,LMTJOIN3 AS LMTJOIN
,DRNKANY5 AS DRNKANY
,DIABETE3 AS DIABETE
,_SMOKER3 AS SMOKER
FROM dataout.test;
;QUIT;
Thanks
Can you tell me why the renamed columns don't export to excel using ods excel file = "" ? The regular variable names are what get exported instead.
Hi @elwayfan446, this sounds like a new question. Want to create a new topic with some sample code? ODS EXCEL is for ODS output, not data sets exactly, so it doesn't really play into PROC SQL unless you're leaving off the CREATE TABLE statement.
Unrelated question: Is there any chance this data is coming from BRFSS?
yes, you worked on it before?
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.