Hi guys,
I imported an excel stats dataset into SAS EG and the year fields "1980-2021" were output as "H=AW". I want to rename these variable names back to "1980-2021" for analysis.
I tried (excerpt):
rename H=1980 I=1981 J=1982 K=1983 L=1984 M=1985 N=1986 O=1987 P=1988 Q=1989 R=1990 S=1991 T=1992
U=1993 V=1994 W=1995 X=1996 Y=1997 Z=1998 AA=1999 AB=2000 AC=2001 AD=2002 AE=2003 AF=2004
AG=2005 AH=2006 AI=2007 AJ=2008 AK=2009 AL=2010 AM=2011 AN=2012 AO=2013 AP=2014 AQ=2015 AR=2016
AS=2017 AT=2018 AU=2019 AV=2020 AW=2021;
but got the error messsage (excerpt):
rename H=1980 I=1981 J=1982 K=1983 L=1984 M=1985 N=1986 O=1987 P=1988 Q=1989 R=1990 S=1991 T=1992
____
22
76
ERROR 22-322: Expecting a name.
ERROR 76-322: Syntax error, statement will be ignored.
Any help?
Thanks
Those aren't valid SAS names, it needs a letter or underscore before the number. SAS variable name rules
rename h=Y1980 i=Y1981;
You could try the following but I'm not sure it will recognize the first set of variables as a sequence.
rename h-av = Y1980-Y2021;
Those aren't valid SAS names, it needs a letter or underscore before the number. SAS variable name rules
rename h=Y1980 i=Y1981;
You could try the following but I'm not sure it will recognize the first set of variables as a sequence.
rename h-av = Y1980-Y2021;
Worked. Thanks a million.
@kinassan wrote:
Hi guys,
I imported an excel stats dataset into SAS EG and the year fields "1980-2021" were output as "H=AW". I want to rename these variable names back to "1980-2021" for analysis.
You might consider going back to the import step and make sure ot use the GETNAMES option. If your data sheet has the names other than row one, delete those rows so the column names are just above the data.
Merged cells are right out though.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.