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!

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 604 views
  • 0 likes
  • 2 in conversation