[sas-users] Comparing the actual dataset layout to the prescribed dataset layout

b.nathaniel.miller at census.gov b.nathaniel.miller at census.gov
Thu Aug 25 14:31:30 EDT 2011


You can put your (keep=name) in your proc contents after out=contents so 
you don't have to do that as an additional datastep:
proc contents data=dataset NODETAILS out=contents (keep=name);
run;

Also, the values you specified for GETNAMES, MIXED, SCANTEXT, USEDATE, and 
SCANTIME are all the default values. At this point, it wouldn't do a lot 
for your efficiency, but if you type up similar programs in the future, 
omitting them would save you some typing.

Have fun!
Nate




From:
josue.delarosa at census.gov
To:
sas-users at lists.census.gov
Date:
08/25/2011 01:44 PM
Subject:
[sas-users] Comparing the actual dataset layout to the prescribed dataset 
layout
Sent by:
sas-users-bounces at lists.census.gov



When verifying files I used to print out a proc contents report and 
compare it to the layout of a file which was prescribed in a 
specification.  Instead of reviewing the variables by pencil and paper 
I?ve been experimenting with the following program.  Any feedback on how 
to make this program more efficient would be appreciated.
 
Thanks,
 
Josh
 
*output contents to dataset;
proc contents data=dataset NODETAILS out=contents;
run;
 
*keep only var names;
data contents2 (keep=name);
set contents;
run;
 
*import layout of file from specification, assumes layout is already in 
excel form;
PROC IMPORT OUT=spec_layout 
            DATAFILE= "C:\...\spec.xls" 
            DBMS=EXCEL REPLACE;
     RANGE="Sheet1$"; 
     GETNAMES=YES;
     MIXED=NO;
     SCANTEXT=YES;
     USEDATE=YES;
     SCANTIME=YES;
RUN;
 
 
proc sort data=spec_layout;
by name;
run;
 
*merge files and look for vars in layout and not in dataset & vice versa;
data not_in_spec not_in_contents ;
merge spec_layout  (in=s) contents2 (in=c);
by name;
if s=1 and c=0 then output not_in_contents;
else if s=0 and c=1 then output not_in_spec;
run;_______________________________________________
sas-users mailing list
sas-users at lists.census.gov
http://lists.census.gov/mailman/listinfo/sas-users


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.census.gov/pipermail/sas-users/attachments/20110825/ba9d124e/attachment.html>


More information about the sas-users mailing list