It's tough for me to explain everything, but hopefully this can give you a better idea of what I want to achieve. Here's an example of a code that achieves what I want to do for WORK.Contact_MS. DATA WORK.Contact_IA ;
RETAIN SSN Inits City StateCd ZipCd;
SET HypImpt.IowaResidents
( RENAME = ( ZipCd = ZipCdNum ) );
ZipCd = PUT(ZipCdNum, 5.);
DROP ZipCdNum;
LABEL SSN = 'Social Security Number'
Inits = 'Subject Initials'
City = 'City'
StateCd = 'State Code'
ZipCd = 'Zip Code';
LENGTH Inits $ 3
StateCd $ 2;
City = PROPCASE(City);
StateCd = CAT(SUBSTR(State, 1, 1), SUBSTR(State, 4,1));
Inits = CATS(SUBSTR(Initials, 3, 2), SUBSTR(Initials, 1, 1));
FORMAT StateCd $StateCd.;
KEEP SSN Inits City StateCd ZipCd;
RUN; My output looks like this for WORK.Contact_IA: Just to give you an idea of what the original data set looks like: Right now, my output for WORK.Contact_MS looks like this: Here is what I see in my log (which doesn't show any errors or warning messages): 1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
72
73 DATAWORK.Contact_MS;
74 RETAIN SSN Inits City StateCd ZipCd;
75
76 LENGTH Inits $3
77 City $20
78 StateCd $2;
79 SETHypImpt.MS_Citizens (RENAME = (SocSecNum = SSN));
80
81 /*RETAIN SSN
82 Inits
83 City
84 StateCd 'MS'
85 ZipCd;*/
86
87 LABEL SSN= 'Social Security Number'
88 Inits= 'Subject Initials'
89 City= 'City'
90 StateCd= 'State Code'
91 ZipCd= 'Zip Code';
92
93
94 /* FirstInit = COMPRESS(FirstInit, '.');
95 MiddleInit = COMPRESS(MiddleInit, '.');
96 LastInit = COMPRESS(LastInit, '.');
97 Inits = FirstInit||MiddleInit||LastInit;
98 City = SCAN(CityState, 1, ' ,');
99 StateCd = SCAN(CityState, 2, ' ,'); */
100
101 City = SCAN(CityState, 1, ' ,');
102 City = PROPCASE(City);
103 StateCd = COMPRESS((SCAN(CityState, 2, ',')));
104 StateCd = UPCASE(StateCd);
105 Inits = CATS(SUBSTR(FirstInit, 1, 1), SUBSTR(MiddleInit, 1, 1), SUBSTR (LastInit, 1, 1));
106
107 FORMAT StateCd $StateCd.; /*if I add this, "Unexpected Value" appears in output*/
108 KEEP SSN Inits City StateCd ZipCd;
109 RUN;
NOTE: Variable StateCd is uninitialized.
NOTE: There were 207 observations read from the data set HYPIMPT.MS_CITIZENS.
NOTE: The data set WORK.CONTACT_MS has 207 observations and 5 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
user cpu time 0.00 seconds
system cpu time 0.00 seconds
memory 1119.18k
OS Memory 32940.00k
Timestamp 11/12/2020 02:28:04 AM
Step Count 362 Switch Count 2
Page Faults 0
Page Reclaims 198
Page Swaps 0
Voluntary Context Switches 23
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 272
110
111
112 PROC SORT DATA = WORK.Contact_MS;
113 BY SSN;
114 RUN;
NOTE: There were 207 observations read from the data set WORK.CONTACT_MS.
NOTE: The data set WORK.CONTACT_MS has 207 observations and 5 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.00 seconds
user cpu time 0.00 seconds
system cpu time 0.01 seconds
memory 1041.50k
OS Memory 32940.00k
Timestamp 11/12/2020 02:28:04 AM
Step Count 363 Switch Count 2
Page Faults 0
Page Reclaims 113
Page Swaps 0
Voluntary Context Switches 11
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 264
115
116 PROC CONTENTS DATA = WORK.Contact_MS ORDER = VARNUM;
117 RUN;
NOTE: PROCEDURE CONTENTS used (Total process time):
real time 0.06 seconds
user cpu time 0.07 seconds
system cpu time 0.00 seconds
memory 3129.90k
OS Memory 33708.00k
Timestamp 11/12/2020 02:28:04 AM
Step Count 364 Switch Count 0
Page Faults 0
Page Reclaims 243
Page Swaps 0
Voluntary Context Switches 2
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 16
118
119 PROC PRINT DATA = WORK.Contact_MS;
120 RUN;
NOTE: There were 207 observations read from the data set WORK.CONTACT_MS.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.30 seconds
user cpu time 0.30 seconds
system cpu time 0.00 seconds
memory 3049.31k
OS Memory 35752.00k
Timestamp 11/12/2020 02:28:05 AM
Step Count 365 Switch Count 0
Page Faults 0
Page Reclaims 643
Page Swaps 0
Voluntary Context Switches 2
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 152
121
122 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
134
... View more