BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
IsoTropic
Fluorite | Level 6

I have several files with the same data elements.

However, in some of these files a prior programmer, omitted some data elements.

Example:   Id, Name, Test1, Test2, Test3, GREVERB, GREVERB2, GMATVERB

some files are missing:  GREVERB, GREVERB2

 

Is there anyway to test that these data elements are missing?

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Take a ook at sashelp.vcolumn which lists all columns in all tables. 

 

You can run a proc freq by column name to see variable frequency. And can query the table to filter the for tables that are missing the variables of interest.

 

View solution in original post

4 REPLIES 4
Reeza
Super User

Take a ook at sashelp.vcolumn which lists all columns in all tables. 

 

You can run a proc freq by column name to see variable frequency. And can query the table to filter the for tables that are missing the variables of interest.

 

IsoTropic
Fluorite | Level 6
I actually know what files are missing the values.
If I did not this would work well.
I will just need to recreate the files with the correct variables.
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Define "files".  Do you mean text files, excel files, SAS datafiles etc.

 

Personally I find this to be a defect in the import process.  A clean process would be:

1) Define Data Transfer Specifications document - this is the basis for everything next and should be agreed and approved by both parties.

2) Create an import progra/check program based on that document

3) Test the process with test data

4) After pass, the document is live and transfer can occur.

5) At each delivery data is checked/imported/validated etc. per the document.  Any failures go directly back to the supplier.

 

It sounds like you don't have this agreement, hence you really don't have much control over what is happening.  I mean what if they decide to include GREVERB, but not TEST1, or maybe they call all the variables XYZ1-XYZ10, or they just write the information on the back of a cornflakes box, scan that in, and send it someone else?  A bit of an extreme example, but the point is the process is everything, and should be thoroughly documented, tested, replicable before and at each time.

ballardw
Super User

Here is an approach using a control data set with the information, library, dataset and variable name of interest, and searching dictionary.columns (or sashelp.vcolumn) to create a data set with the information and an added variable "found" which will have a value of 1 when found (exists) or 0 when it doesn't.

 

The example has the desired information in uppercase for consistency. The dictionary table will have the Library and dataset name in upper case as well. Variable names seem to be a bit more flexible as to case so I force an uppercase comparison.

 

Data control;
   informat libname $8. setname $32. varname $32.;
   input libname setname varname;
datalines;
SASHELP CLASS AGE
SASHELP CLASS WEIGHT
SASHELP CLASS XYZZY
;
RUN; 

PROC SQL;
   create table foundit as
   select control.libname, control.setname, control.varname,
          (control.varname=upcase(b.name)) as found
   from control left join dictionary.columns as b on
        control.libname=b.libname and control.setname=b.memname
        and control.varname=upcase(b.name)
   ;
quit;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1009 views
  • 0 likes
  • 4 in conversation