DATA Step, Macro, Functions and more

How to accomplish this

Reply
Contributor
Posts: 40

How to accomplish this

I want to loop thru each of record to see if value in a particular date fields gets changed over time. There are multiple records for same entity in my table(kind of history table).

Any idea how to do this using data setp/proc sql.

thanks in advance,

sasbase

Contributor
Posts: 66

Re: How to accomplish this

can you give me some more details as to how the data is stored? a list of column names for example...

Contributor
Posts: 40

Re: How to accomplish this

For example,

I have a table where historical info related to that entity is stored over time.

Entity_ID, col 2 , col 3 ...etc , and few date fields. So I want to check if a particular entity id is changed over time(against one of date fields) or not ?


Contributor
Posts: 44

Re: How to accomplish this

You may want to show some sample data and sample output.  I'm guessing you want something like:


data have;
  input entity_id $4. datecol1 ddmmyy8.;
  format datecol1 mmddyy8.;
  datalines;
1234 010111
1234 010111
1234 010111
1234 030111
1235 020111
1235 020111
1235 030111
1235 040111
  ;
run;

proc sql;
  select distinct entity_id, datecol1 from have;
quit;

Output would be:

entity_id  datecol1  

---------       ----------  

1234       01/01/11  

1234       01/03/11  

1235       01/02/11  

1235       01/03/11  

1235       01/04/11 

                                             


Super User
Posts: 17,868

Re: How to accomplish this

Not 100% clear on what you're looking for, an example of what your data looks like would be helpful.

Using Jason data the following will give you distinct entries for records where the datecol1 are have different entries. You can remove the distinct keyword for all entries instead.

proc sql;

     create table want as

    select distinct * from have

    group by entity_id

    having min(datecol1) ne max(datecol1);

quit;

Super User
Posts: 9,682

Re: How to accomplish this

I think you should post some sample data and output you want to clarify your question.

Ksharp

Ask a Question
Discussion stats
  • 5 replies
  • 252 views
  • 0 likes
  • 5 in conversation