BookmarkSubscribeRSS Feed
Vijendra_SAS
Calcite | Level 5

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

9 REPLIES 9
Reeza
Super User

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?

Vijendra_SAS
Calcite | Level 5

hi

I am comparing one row against another row..

Reeza
Super User

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.

Vijendra_SAS
Calcite | Level 5

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

Reeza
Super User

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.

Vijendra_SAS
Calcite | Level 5

Hi

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

Vijendra_SAS
Calcite | Level 5

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 )

Reeza
Super User

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;

Astounding
PROC Star

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.

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 9 replies
  • 1147 views
  • 0 likes
  • 3 in conversation