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.
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 ;
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 |
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
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.
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
Yes. As above said. You need to post sample data , your code and the whole LOG .
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.
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.