BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
kinassan
Calcite | Level 5

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

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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;

View solution in original post

3 REPLIES 3
Reeza
Super User

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;
kinassan
Calcite | Level 5

Worked. Thanks a million.

ballardw
Super User

@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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 3 replies
  • 1957 views
  • 1 like
  • 3 in conversation