Hello SAS Communities,
I am working on a code but have some errors, below what I need to do:-
1. to concatenate three variables ( FirstInit, MiddleInit, LastInit) into one variable named Inits.
2. Extract the "City" from Text Strings(CityState).
3. Extract the "StateCd" from Text Strings(CityState).
My Code looks like this
DATA ..... ;
LENGTH SocSecNum $11
FirstInit $2
MiddleInit $2
LastInit $2
CityState $35
ZipCD $5;
SET .... (RENAME=(SocSecNum= SSN));
FirstInit = COMPRESS(FirstInit,'.');
MiddleInit = COMPRESS(MiddleInit,'.');
LastInit = COMPRESS(LastInit,'.')
Inits = CATS(FirstInit,MiddleInit,LastInit);
City = SCAN(CityState, 1, ' ,');
StateCd = SCAN(CityState, 2, ' ,');
KEEP SSN
Inits
City
StateCd
ZipCd;
RUN;
Here what the log looks like
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
72
73 DATA WORK.Contact_MS ;
74 LENGTH SocSecNum $11
75 FirstInit $2
76 MiddleInit $2
77 LastInit $2
78 CityState $35
79 ZipCD $5;
80 SET .... (RENAME=(SocSecNum= SSN));
81
82
83 FirstInit = COMPRESS(FirstInit,'.');
84 MiddleInit = COMPRESS(MiddleInit,'.');
85 LastInit = COMPRESS(LastInit,'.')
86 Inits = CATS(FirstInit,MiddleInit,LastInit);
_____
22
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, *, **, +, -, /, ;, <, <=, <>, =, >, ><, >=, AND, EQ, GE, GT,
IN, LE, LT, MAX, MIN, NE, NG, NL, NOTIN, OR, ^=, |, ||, ~=.
87 City = SCAN(CityState, 1, ' ,');
88 StateCd = SCAN(CityState, 2, ' ,');
89 KEEP SSN
90 Inits
91 City
92 StateCd
93 ZipCd;
94
95 RUN;
NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).
85:22 86:22
NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column).
1:1
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set ... may be incomplete. When this step was stopped there were 0 observations and 5 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
96
97 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
THANK YOU!
... View more