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

I hope this is an easy question for sasperts.

I am updating the previous 10 year trend data with new data, to make a new 10 year trend data set.

old data set is indicators2008_2017

adding in data for 2018, so for the new 10 year trend data set, i want the data set to be indicators2009_2018

 

Is this right?

**** edit Year ******************** ;
%let Year = 2018 ;
/* these two lines are to identify the previous 10 year data set, that ends with the year -before- "year" and begins with year - 10.
For example, when updating with 2018 data, the previous data set was indicators2008_2017 */
%let oldendyr=%eval(&Year-1);
%let oldstartyr=%eval(&Year-10);

* AND need the first year of the new 10 year data set, which would be year -9 ;
%let newstartyr=%eval(&Year-9);

 

 

Then next, I'm trying to bring together the data for the current year with the data with the previous data set. I know this isn't right because I get errors.


data indicators&newstartyr_&Year;
set sasout.indicators&oldstartyr_&oldendyr
indicators&Year;
run;

 

 

Here is some output


2836 data indicators&newstartyr_&Year;

(next three lines below under the & symbol)

-
22
200
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, (, /, ;,
_DATA_, _LAST_, _NULL_.

ERROR 200-322: The symbol is not recognized and will be ignored.

 

Help appreciated.

 

Thanks

 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

So you ran this?

%let Year = 2018 ;
%let oldendyr=%eval(&Year-1);
%let oldstartyr=%eval(&Year-10);
%let newstartyr=%eval(&Year-9);
data indicators&newstartyr_&Year;
  set sasout.indicators&oldstartyr_&oldendyr indicators&Year;
run;

If so you are referencing two macro variables named NEWSTARTYR_ and OLDSTARTYR_ that you never defined.

 

You must use a period to let the macro processor know where the macro variable name ends when you have appended some other characters that could be part of the name.

data indicators&newstartyr._&Year;
  set sasout.indicators&oldstartyr._&oldendyr indicators&Year;
run;

 

View solution in original post

2 REPLIES 2
Tom
Super User Tom
Super User

So you ran this?

%let Year = 2018 ;
%let oldendyr=%eval(&Year-1);
%let oldstartyr=%eval(&Year-10);
%let newstartyr=%eval(&Year-9);
data indicators&newstartyr_&Year;
  set sasout.indicators&oldstartyr_&oldendyr indicators&Year;
run;

If so you are referencing two macro variables named NEWSTARTYR_ and OLDSTARTYR_ that you never defined.

 

You must use a period to let the macro processor know where the macro variable name ends when you have appended some other characters that could be part of the name.

data indicators&newstartyr._&Year;
  set sasout.indicators&oldstartyr._&oldendyr indicators&Year;
run;

 

geneshackman
Pyrite | Level 9
Thanks!

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 2 replies
  • 677 views
  • 2 likes
  • 2 in conversation