How many times I can use and condition when I like to tag something.
for example:-
these are datasets follows:-
data lowl_high;
input loanid $ Gender$ Married$ Depender Education$ Self_employed$ Applicantincome Coapplicantincome Loanamount Loan_amount_term Credit_history Propertyarea$ ;
datalines;
LP001011 male Yes 0 Graduate No 5720 0 110 360 1 Urban
LP001012 female Yes 1 Graduate No 5730 0 112 372 2 SemiUrban
LP001013 female No 2 NonGraduate Yes 5740 1 114 380 3 Urban
LP001014 male No 0 Graduate No 5750 1 115 390 2 Semiurban
LP001015 female Yes 1 NonGraduate Yes 5760 0 116 400 1 Semiurban
LP001016 male No 0 Graduate Yes 5770 2 117 410 0 Urban
LP001017 female Yes 1 Graduate No 5780 1 118 420 1 Semiurban
but I am facing problem regarding this query:-
data Important9;
set Lowl_high;
Length Tag $15;
if Gender="female" and Married="Yes" and Education="Graduate" then Tag="High";
Else Tag="Low";
Run;
kindly help
I ran your code. It seems to work fine. Below is the log:
3178 data lowl_high;
3179 input loanid $ Gender$ Married$ Depender Education$ Self_employed$
3179! Applicantincome Coapplicantincome Loanamount Loan_amount_term
3179! Credit_history Propertyarea$ ;
3180 datalines;
NOTE: The data set WORK.LOWL_HIGH has 7 observations and 12 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds
3188 ;
3189 data Important9;
3190 set Lowl_high;
3191 Length Tag $15;
3192 if Gender="female" and Married="Yes" and Education="Graduate" then
3192! Tag="High";
3193 Else Tag="Low";
3194 Run;
NOTE: There were 7 observations read from the data set WORK.LOWL_HIGH.
NOTE: The data set WORK.IMPORTANT9 has 7 observations and 13 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
Results:/*is this your expected result?*/
| loanid | Gender | Married | Depender | Education | Self_employed | Applicantincome | Coapplicantincome | Loanamount | Loan_amount_term | Credit_history | Propertyarea | Tag |
| LP001011 | male | Yes | 0 | Graduate | No | 5720 | 0 | 110 | 360 | 1 | Urban | Low |
| LP001012 | female | Yes | 1 | Graduate | No | 5730 | 0 | 112 | 372 | 2 | SemiUrba | High |
| LP001013 | female | No | 2 | NonGradu | Yes | 5740 | 1 | 114 | 380 | 3 | Urban | Low |
| LP001014 | male | No | 0 | Graduate | No | 5750 | 1 | 115 | 390 | 2 | Semiurba | Low |
| LP001015 | female | Yes | 1 | NonGradu | Yes | 5760 | 0 | 116 | 400 | 1 | Semiurba | Low |
| LP001016 | male | No | 0 | Graduate | Yes | 5770 | 2 | 117 | 410 | 0 | Urban | Low |
| LP001017 | female | Yes | 1 | Graduate | No | 5780 | 1 | 118 | 420 | 1 | Semiurba | High |
what is the problem? Please help understand the problem
I ran your code. It seems to work fine. Below is the log:
3178 data lowl_high;
3179 input loanid $ Gender$ Married$ Depender Education$ Self_employed$
3179! Applicantincome Coapplicantincome Loanamount Loan_amount_term
3179! Credit_history Propertyarea$ ;
3180 datalines;
NOTE: The data set WORK.LOWL_HIGH has 7 observations and 12 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds
3188 ;
3189 data Important9;
3190 set Lowl_high;
3191 Length Tag $15;
3192 if Gender="female" and Married="Yes" and Education="Graduate" then
3192! Tag="High";
3193 Else Tag="Low";
3194 Run;
NOTE: There were 7 observations read from the data set WORK.LOWL_HIGH.
NOTE: The data set WORK.IMPORTANT9 has 7 observations and 13 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
Results:/*is this your expected result?*/
| loanid | Gender | Married | Depender | Education | Self_employed | Applicantincome | Coapplicantincome | Loanamount | Loan_amount_term | Credit_history | Propertyarea | Tag |
| LP001011 | male | Yes | 0 | Graduate | No | 5720 | 0 | 110 | 360 | 1 | Urban | Low |
| LP001012 | female | Yes | 1 | Graduate | No | 5730 | 0 | 112 | 372 | 2 | SemiUrba | High |
| LP001013 | female | No | 2 | NonGradu | Yes | 5740 | 1 | 114 | 380 | 3 | Urban | Low |
| LP001014 | male | No | 0 | Graduate | No | 5750 | 1 | 115 | 390 | 2 | Semiurba | Low |
| LP001015 | female | Yes | 1 | NonGradu | Yes | 5760 | 0 | 116 | 400 | 1 | Semiurba | Low |
| LP001016 | male | No | 0 | Graduate | Yes | 5770 | 2 | 117 | 410 | 0 | Urban | Low |
| LP001017 | female | Yes | 1 | Graduate | No | 5780 | 1 | 118 | 420 | 1 | Semiurba | High |
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.