BookmarkSubscribeRSS Feed
huanaca
Calcite | Level 5

Thank you for your response.  I am getting an error with every update statement:

ERROR: UPDATE statement needs a BY statement.

thanks in advance for any help with this.

RichardinOz
Quartz | Level 8

Sorry - left out the by statement  - not able to check!

Assuming all your data is sorted by StdPseudoId and this is a unique key to the data then you need

%Macro NextYear(yr) ;

  Data Want ;

     Update want

                Demog&yr ;

     By StdPseudoId ;

  Run ;

%Mend ;

huanaca
Calcite | Level 5

Richard,

Thanks very much, the code ran without error. However, the resulting file includes all variables from all datasets. Rather than using information from all the datasets to create one set of variables, this code created a dataset that combined the variables.  So it gave me this:

1

StdPseudoId

2

LangClsCode02

3

ELIdentDate02

4

StdELRedesigDate02

5

StdDob02

6

Gender02

7

Ethnicity02

8

HomeLang02

9

FRLunch02

10

ParentEduLevel02

11

US1stSchoolDate02

12

CA1stSchoolDate02

13

GradeFirstEnroll02

14

LangClsCode03

15

ELIdentDate03

16

StdELRedesigDate03

17

StdDob03

18

Gender03

19

Ethnicity03

20

HomeLang03

21

FRLunch03

22

ParentEduLevel03

23

US1stSchoolDate03

24

CA1stSchoolDate03

25

GradeFirstEnroll03

etc.

.

.

.

98

LangClsCode10

99

ELIdentDate10

100

StdELRedesigDate10

101

StdDob10

102

Gender10

103

Ethnicity10

104

HomeLang10

105

FRLunch10

106

ParentEduLevel10

107

US1stSchoolDate10

108

CA1stSchoolDate10

109

GradeFirstEnroll10

Ksharp
Super User

Or you don't need to rename all .

SQL can take care of it all.

proc sql;

create table want as

select  LangClsCode02 as LangClsCode,

         ELIdentDate02 as ELIdentDate,

          StdELRedesigDate02 as StdELRedesigDate,

          StdDob02 as StdDob,

          Gender02 as Gender ,

         Ethnicity02 as Ethnicity ,

         HomeLang02 as HomeLang,

          FRLunch02 as FRLunch,

         ParentEduLevel02 as ParentEduLevel ,

         US1stSchoolDate02 as US1stSchoolDate,

          CA1stSchoolDate02 as CA1stSchoolDate,

         GradeFirstEnroll02 as GradeFirstEnroll

from  Demog01_02

union

select * from  Demog02_03

union

select * from  Demog03_04

union

..........

;

quit;





Ksharp

huanaca
Calcite | Level 5

thanks for your help.  I am getting an error message with this syntax, at the final semi-colon:

     ;

     -

     22

     76

ERROR 22-322: Syntax error, expecting one of the following: (, ALL, CORR, CORRESPONDING, SELECT.

ERROR 76-322: Syntax error, statement will be ignored.

LarryWorley
Fluorite | Level 6

huanaca,

When posting log error messages, it is generally helpful to post all of the data step or proc sql log listing, so we can see the context of your error message.

Both of your error postings are too short to provide definitive answers to them:-)

Larry

Ksharp
Super User

Yes. As above said. You need to post sample data , your code and the whole LOG .

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is Bayesian Analysis?

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 21 replies
  • 3223 views
  • 0 likes
  • 6 in conversation