BookmarkSubscribeRSS Feed
Unstefan
Calcite | Level 5

Hello SAS<

I have the following data base :

NOCONTprodDPD_0DPD0CDSITC1STARE1TOTAL11DPD_1DPD1Scadentadtcsts03DPD_WCS_riscWCSDPD_wcsdiferenta
500338833CR0B0. 01A2925.076259B1. 1-3..3911/30/18.0
500354163CR8B1. 1-301A667.7537539B2. 31-..6911/30/18.0
500366287CR0B0. 01A0.489B1. 1-32210/22/183911/30/18391
500403009CR39B2. 31-601A1725.0787539B2. 31-2209/22/186911/30/18691

 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

5 REPLIES 5
Kurt_Bremser
Super User

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.

Unstefan
Calcite | Level 5

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 ??

Unstefan
Calcite | Level 5

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

Kurt_Bremser
Super User

@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.

Unstefan
Calcite | Level 5

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

 

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!
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
  • 5 replies
  • 867 views
  • 0 likes
  • 2 in conversation