Help using Base SAS procedures

comparing of observation in single SAS data file

Reply
Occasional Contributor
Posts: 5

comparing of observation in single SAS data file

usually we use Proc Compare for comparing two sas datasets and their observation, variable.

is there any way we can compare the observation with in single sas datasets with eachother ? which procedure we use ? what is syntax ?

please let me know ASAP

Super User
Posts: 17,750

Re: comparing of observation in single SAS data file

That depends on what you're trying to do.

What are you trying to do? Compare one variable against another variable? Compare one row against a different/all rows?

Occasional Contributor
Posts: 5

Re: comparing of observation in single SAS data file

hi

I am comparing one row against another row..

Super User
Posts: 17,750

Re: comparing of observation in single SAS data file

There are ways to make proc compare do that, but you'll need to replicate your dataset and indicate which rows are compared against which.


It's probably easier to go with a manual data step or a sql step.

If you want further advice, you'll need to provide more detailed information.

Occasional Contributor
Posts: 5

Re: comparing of observation in single SAS data file

i have file , I couldnot attach it to conversation.. let me know your mail id.. I can send it across.. and we can discuss

Super User
Posts: 17,750

Re: comparing of observation in single SAS data file

No thanks, attach here (edit your first post), or preferably recreate a simple sample that you can paste into the window.

IE usually won't allow you to paste, so you might need to use FireFox or Chrome.

Occasional Contributor
Posts: 5

Re: comparing of observation in single SAS data file

Hi

i tried to attach file in my first post, you may refer there , about what I want to know.

Occasional Contributor
Posts: 5

Re: comparing of observation in single SAS data file

In attached file , I want to check if Field_Name across all the Form_Name have same definition or not ? if its varies even by space, comma or fullstop , my SAS program should give me out file with those difference.

I have applied filter , just for convenience of your understanding.

let me know which function I can use ?  ( I am aware of lag function.. but not able to put inform of sytax )

Super User
Posts: 17,750

Re: comparing of observation in single SAS data file

You don't specify what you want your output to look like.

Sort your data by Field_Name and use first./last. processing in addition to the definition. If the definition varies while the field name is the same it will flag it.

I don't think this is quite right, but you can review the first/last processing and see what works for you.

proc sort data=have; by form_name field_name definition; run;

data want;

set have;

by form_name field_name;

if first.field_name and not (first.definition and last.definition) then flag=1;

else flag=0;

run;

Super User
Posts: 5,071

Re: comparing of observation in single SAS data file

Maybe what you really want is as simple as this:

proc freq data=have;

   tables field_name;

run;

If not, it might be this:

proc freq data=have;

   tables form_name * field_name / missing list;

run;

It won't point out which rows you need to fix, but it will find the spelling variations.

Ask a Question
Discussion stats
  • 9 replies
  • 301 views
  • 0 likes
  • 3 in conversation