BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
etremblay94
Calcite | Level 5

Hi All! 

 

Im trying to work with some Covid data and having a hard time parsing out New Cases. Now the data has an instance for each date (FNDate) with the "Cofirmed" value of cases. The next instance the Confirmed value is the previous day plus new cases. It is additionally tricky because there is an istance for each country for each day so it needs it by country. I've attached an output (first 10 instances) of the file for column names.

 

Any thoughts would be super helpful!

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

What is the question here?
Are you trying to take the difference between the current value and the previous value? If so use the DIF() function.

Try something like this (make sure the data is sorted first).

data want;
  set have;
  by country date ;
  new_cases = dif(cases);
  if first.country then new_cases=cases;
run;

View solution in original post

2 REPLIES 2
Tom
Super User Tom
Super User

What is the question here?
Are you trying to take the difference between the current value and the previous value? If so use the DIF() function.

Try something like this (make sure the data is sorted first).

data want;
  set have;
  by country date ;
  new_cases = dif(cases);
  if first.country then new_cases=cases;
run;
etremblay94
Calcite | Level 5

Thank you! This worked perfectly!

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 2 replies
  • 520 views
  • 0 likes
  • 2 in conversation