BookmarkSubscribeRSS Feed
sasbasls
Calcite | Level 5

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

5 REPLIES 5
asishgautam
Calcite | Level 5

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

sasbasls
Calcite | Level 5

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 ?


JasonDiVirgilio
Quartz | Level 8

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 

                                             


Reeza
Super User

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;

Ksharp
Super User

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

Ksharp

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 5 replies
  • 884 views
  • 0 likes
  • 5 in conversation