BookmarkSubscribeRSS Feed
manisolimani
Calcite | Level 5

I am rather a beginner in SAS. I have the following problem. Given is a big data set (my_time) which I imported into SAS looking as follows

sas_1.JPG

 

I want to implement the following algorithm for every account look for a status and if it is equal to na then look for the same contract after one year (one year after it gets the status na) and put the information "my_date", "status" and "money" in three new columns "new_my_date", "new_status" and "new_money" like in

sas_2.JPG

 

I

need something like countifs in excel. I found loops in SAS like DO but not for the purpose to look through all rows. I do not even know for which key word I have to look.

I would be grateful for any hint.

1 REPLY 1
LinusH
Tourmaline | Level 20

There are many ways to solve this.

One could be to join the table with itself, with a join condition like a.year = year+1.

 

Another would be some kind of data step processing using retain, but that would require the data to be sorted first.

 

What has PROC HADOOP to do with anything in your inquiry? 

Data never sleeps

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
  • 1 reply
  • 726 views
  • 0 likes
  • 2 in conversation