I have been head-banging on this one for several days. Seems there should just be a command like "append blank". I have been working with PUTVARC, but SAS keeps complaining about the syntax, and I cannot figure out what I'm doing wrong. Does someone out there have a way of doing this with some code examples? Here is the code I have tried that doesn't work:
options nofmterr yearcutoff=1910 mprint symbolgen;
DATA RESULTS;
LENGTH CATEGORY $42.;
LENGTH REGION $13.;
LENGTH RANGE $42.;
LENGTH POP80 8.;
LENGTH POP81 8.;
LENGTH POP82 8.;
LENGTH POP83 8.;
LENGTH POP84 8.;
LENGTH POP85 8.;
LENGTH POP86 8.;
LENGTH POP87 8.;
LENGTH POP88 8.;
LENGTH POP89 8.;
RUN;
DATA ONE;
SET RESULTS;
CATEGORY='RACE';
REGION='APACHE';
RANGE='WHITE NON-HISPANIC';
RUN;
TERM:
tidnum=open('work.one','u');
vnum=varnum('work.one','RANGE');
rc=locatec(tidnum,vnum,'WHITE NON-HISPANIC','u');
if (rc>0) then
do;
call putvarc(tidnum,vnum,'BLACK NON-HISPANIC');
rc=update(tidnum);
end;
rc=close(tidnum);
RETURN;
And here is the log I get from that code:
NOTE: SAS 9.1.3 Service Pack 2
NOTE: SAS initialization used:
real time 2.43 seconds
cpu time 0.98 seconds
1 options nofmterr yearcutoff=1910 mprint symbolgen;
2
3 DATA RESULTS;
4 LENGTH CATEGORY $42.;
5 LENGTH REGION $13.;
6 LENGTH RANGE $42.;
7 LENGTH POP80 8.;
8 LENGTH POP81 8.;
9 LENGTH POP82 8.;
10 LENGTH POP83 8.;
11 LENGTH POP84 8.;
12 LENGTH POP85 8.;
13 LENGTH POP86 8.;
14 LENGTH POP87 8.;
15 LENGTH POP88 8.;
16 LENGTH POP89 8.;
17 RUN;
NOTE: Variable CATEGORY is uninitialized.
NOTE: Variable REGION is uninitialized.
NOTE: Variable RANGE is uninitialized.
NOTE: Variable POP80 is uninitialized.
NOTE: Variable POP81 is uninitialized.
NOTE: Variable POP82 is uninitialized.
NOTE: Variable POP83 is uninitialized.
NOTE: Variable POP84 is uninitialized.
NOTE: Variable POP85 is uninitialized.
NOTE: Variable POP86 is uninitialized.
NOTE: Variable POP87 is uninitialized.
NOTE: Variable POP88 is uninitialized.
NOTE: Variable POP89 is uninitialized.
NOTE: The data set WORK.RESULTS has 1 observations and 13 variables.
NOTE: DATA statement used (Total process time):
real time 0.26 seconds
cpu time 0.06 seconds
18
19 DATA ONE;
20 SET RESULTS;
21 CATEGORY='RACE';
22 REGION='APACHE';
23 RANGE='WHITE NON-HISPANIC';
24 RUN;
NOTE: There were 1 observations read from the data set WORK.RESULTS.
NOTE: The data set WORK.ONE has 1 observations and 13 variables.
NOTE: DATA statement used (Total process time):
real time 0.04 seconds
cpu time 0.03 seconds
25
26 TERM:
27 tidnum=open('work.one','u');
------
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
28 vnum=varnum('work.one','RANGE');
----
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
29 rc=locatec(tidnum,vnum,'WHITE NON-HISPANIC','u');
--
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
30 if (rc>0) then
--
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
31 do;
32 call putvarc(tidnum,vnum,'BLACK NON-HISPANIC');
----
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
33 rc=update(tidnum);
--
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
34 end;
---
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
35 rc=close(tidnum);
--
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
36 RETURN;
------
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
I don't know why it keeps saying the statements are not valid or are used out of proper order.
options nofmterr yearcutoff=1910 mprint symbolgen;
DATA RESULTS;
LENGTH CATEGORY $42.;
LENGTH REGION $13.;
LENGTH RANGE $42.;
LENGTH POP80 8.;
LENGTH POP81 8.;
LENGTH POP82 8.;
LENGTH POP83 8.;
LENGTH POP84 8.;
LENGTH POP85 8.;
LENGTH POP86 8.;
LENGTH POP87 8.;
LENGTH POP88 8.;
LENGTH POP89 8.;
RUN;
DATA ONE;
SET RESULTS;
CATEGORY='RACE';
REGION='APACHE';
RANGE='WHITE NON-HISPANIC';
RUN;
TERM:
tidnum=open('work.one','u');
vnum=varnum('work.one','RANGE');
rc=locatec(tidnum,vnum,'WHITE NON-HISPANIC','u');
if (rc>0) then
do;
call putvarc(tidnum,vnum,'BLACK NON-HISPANIC');
rc=update(tidnum);
end;
rc=close(tidnum);
RETURN;
And here is the log I get from that code:
NOTE: SAS 9.1.3 Service Pack 2
NOTE: SAS initialization used:
real time 2.43 seconds
cpu time 0.98 seconds
1 options nofmterr yearcutoff=1910 mprint symbolgen;
2
3 DATA RESULTS;
4 LENGTH CATEGORY $42.;
5 LENGTH REGION $13.;
6 LENGTH RANGE $42.;
7 LENGTH POP80 8.;
8 LENGTH POP81 8.;
9 LENGTH POP82 8.;
10 LENGTH POP83 8.;
11 LENGTH POP84 8.;
12 LENGTH POP85 8.;
13 LENGTH POP86 8.;
14 LENGTH POP87 8.;
15 LENGTH POP88 8.;
16 LENGTH POP89 8.;
17 RUN;
NOTE: Variable CATEGORY is uninitialized.
NOTE: Variable REGION is uninitialized.
NOTE: Variable RANGE is uninitialized.
NOTE: Variable POP80 is uninitialized.
NOTE: Variable POP81 is uninitialized.
NOTE: Variable POP82 is uninitialized.
NOTE: Variable POP83 is uninitialized.
NOTE: Variable POP84 is uninitialized.
NOTE: Variable POP85 is uninitialized.
NOTE: Variable POP86 is uninitialized.
NOTE: Variable POP87 is uninitialized.
NOTE: Variable POP88 is uninitialized.
NOTE: Variable POP89 is uninitialized.
NOTE: The data set WORK.RESULTS has 1 observations and 13 variables.
NOTE: DATA statement used (Total process time):
real time 0.26 seconds
cpu time 0.06 seconds
18
19 DATA ONE;
20 SET RESULTS;
21 CATEGORY='RACE';
22 REGION='APACHE';
23 RANGE='WHITE NON-HISPANIC';
24 RUN;
NOTE: There were 1 observations read from the data set WORK.RESULTS.
NOTE: The data set WORK.ONE has 1 observations and 13 variables.
NOTE: DATA statement used (Total process time):
real time 0.04 seconds
cpu time 0.03 seconds
25
26 TERM:
27 tidnum=open('work.one','u');
------
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
28 vnum=varnum('work.one','RANGE');
----
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
29 rc=locatec(tidnum,vnum,'WHITE NON-HISPANIC','u');
--
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
30 if (rc>0) then
--
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
31 do;
32 call putvarc(tidnum,vnum,'BLACK NON-HISPANIC');
----
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
33 rc=update(tidnum);
--
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
34 end;
---
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
35 rc=close(tidnum);
--
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
36 RETURN;
------
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
I don't know why it keeps saying the statements are not valid or are used out of proper order.