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

S_Mario_1-1678112933606.png

 

this is a piece of my output.

what I want to get is the difference between the value of "Diff" when "Flag" =1 and the value of "Diff" when "Flag" =0 for each "Date" as happens on line 4 where 57(flag=1) - 7 (flag=0) = 50 on 01/02/2020.

The result of diff_flag comes from the following data step:

data want;
set have;
by date;
diff_flag = dif(Diff);
run;

Thanks in advance for your help

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Please post your data as text, not as an image. To work with it, we'd have to type it out or convert it to text which is an extra step in trying to help you. 

Preferably a data step, but text at minimum.

 

I think you only want the results when flag=1? If so, delete the results on 0. 

Otherwise, please clarify your expected output.

 

data want;
set have;
by date;
diff_flag = dif(Diff);

if flag_servisizio=0 then call missing(diff_flag);

run;

 

 

 

View solution in original post

2 REPLIES 2
Reeza
Super User

Please post your data as text, not as an image. To work with it, we'd have to type it out or convert it to text which is an extra step in trying to help you. 

Preferably a data step, but text at minimum.

 

I think you only want the results when flag=1? If so, delete the results on 0. 

Otherwise, please clarify your expected output.

 

data want;
set have;
by date;
diff_flag = dif(Diff);

if flag_servisizio=0 then call missing(diff_flag);

run;

 

 

 

S_Mario
Calcite | Level 5
@Reeza sorry for how I put the problem, I'll take it into account for next time.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 755 views
  • 1 like
  • 2 in conversation