- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I have several databases, one per geographical variables, that I want to append in the end. I am doing some data steps on them. As I have large databases, I select only the variables I need when I first call each table. But on tables in which one variable always equals 0, the variable is not in the table.
So when I select my (keep=var) in a for loop, it works fine if the variable exists, but it produces an error in the other case, so that these tables are ignored.
do i=1 to 10 ;
data temp;
set area_i(keep= var1 var2);
run;
proc append base=want
data=temp force;run;
Is there a simple way to tackle that ?
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
DKRICOND=ERROR | WARN | WARNING | NOWARN
DKROCOND=ERROR | WARN | WARNING | NOWARN
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You can suppress the generation of an ERROR with options nodsfnerr;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I did not find any occurence of your option :smileyconfused:
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Brain fart. SAS(R) 9.2 Language Reference: Dictionary, Fourth Edition describes it, but it is used to suppress errors caused by nonexisting datasets.
Xia Keshan has the correct solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
DKRICOND=ERROR | WARN | WARNING | NOWARN
DKROCOND=ERROR | WARN | WARNING | NOWARN
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
It worked, thanks a lot !
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You could also create an empty template dataset, and set this with your data so the variables you require are never missing:
proc sql;
create table TEMPLATE (VAR1 char(200),VAR2 char(200));
quit;
data temp (keep=var1 var2) ;
set area_i template;
run;
That way temp will always have var1 and var2.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I am afraid it will add too much time, as it adds one dataset creation. I have millions of observations, so this might matters.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Sorry, I was going on the example you had given. If you are dealing with large amount of datasets then you want a better way of working. Check the metadata and then generate the program from that. Whilst there are ways to get around warnings and such like, they do come out for a reason. IMO I would try to fix these rather than remove them from the log. E.g.
proc sql;
select distinct NAME
into :TABLE1 separated by " "
from SASHELP.VCOLUMN
where LIBNAME="WORK"
and MEMNAME="DATASET"
and NAME in ("VAR1","VAR2");
select distinct NAME
into :TABLE2 separated by " "
from SASHELP.VCOLUMN
where LIBNAME="WORK"
and MEMNAME="DATASET"
and NAME in ("VAR1","VAR2");
/* Note, probably easier ways to get the macro lists I am typing this quickly */
quit;
data want;
set table1 (keep=id &table1.)
table2 (keep=id &table2.);
run;