Hello SAS<
I have the following data base :
NOCONT | prod | DPD_0 | DPD0 | CDSITC1 | STARE1 | TOTAL11 | DPD_1 | DPD1 | Scadenta | dtcsts03 | DPD_WCS_risc | WCS | DPD_wcs | diferenta |
500338833 | CR | 0 | B0. 0 | 1 | A | 2925.07625 | 9 | B1. 1-3 | . | . | 39 | 11/30/18 | . | 0 |
500354163 | CR | 8 | B1. 1-30 | 1 | A | 667.75375 | 39 | B2. 31- | . | . | 69 | 11/30/18 | . | 0 |
500366287 | CR | 0 | B0. 0 | 1 | A | 0.48 | 9 | B1. 1-3 | 22 | 10/22/18 | 39 | 11/30/18 | 39 | 1 |
500403009 | CR | 39 | B2. 31-60 | 1 | A | 1725.07875 | 39 | B2. 31- | 22 | 09/22/18 | 69 | 11/30/18 | 69 | 1 |
I need some hits about some filters and conditions that I want to apply to database
I want to add a new column with 'Tipp' name
in tipp column I need the following filters :
- if diferenta =1 and DPD1=b1. 1-3 and 31>=dpd_wcs<=60 then B2
- if diferenta =1 and DPD1=b1. 1-3 and dpd_wcs < 31 then X
- if diferenta =1 and DPD1=b1. 1-3 and dpd_wcs>=61 then B3
thank you
Please try to create some data for testing out of your post. You will then understand why we want example data in a usable form, namely in a data step with datalines.
data rrl2;
set rrl1;
if diferenta=1 then do ;
if dpd1=B1. 1-3 then do ;
if dpd_wcs<=30 then tipp=X;else tipp=B2; end;
else do;
if DPD_wcs<=60 then tipp=B2;else tipp=B3; end;
end;
something like that will work ??
it doesn't work ,
I run without error but instead of completing tipp column , the program add me 3 columns tipp , X, B2 si B3
I have the following message:
NOTE: Variable X is uninitialized.
NOTE: Variable B2 is uninitialized.
NOTE: Variable B3 is uninitialized.
NOTE: There were 23995 observations read from the data set WORK.RRL
@Unstefan wrote:
it doesn't work ,
I run without error but instead of completing tipp column , the program add me 3 columns tipp , X, B2 si B3
I have the following message:
NOTE: Variable X is uninitialized.
NOTE: Variable B2 is uninitialized.
NOTE: Variable B3 is uninitialized.
NOTE: There were 23995 observations read from the data set WORK.RRL
Example data, please. Once again: IN A DATA STEP WITH DATALINES!
And the whole log, with the code. Combining this with your data will let us find the mistake.
data rrl1;
set rrl;
if diferenta='0' then tipp="X";
if diferenta=1 then do ;
if dpd1='B1. 1-3' then do ;
if dpd_wcs<=30 then tipp="X";else tipp="B2. 31-"; end;
else do;
if DPD_wcs<=60 then tipp="B2. 31-";else tipp="B3. 61-"; end;
end;
format tipp $7.;
run;
here is the code , it doesn't return me the X value and the B2 and B3
It only returns blank instead of X and only B for b2 and b3
I format the tipp text because the DPD1 is text too
something is wrong here bun I don't know what
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!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.