I'm just getting started and it's very simple code in SAS University. What am I doing wrong?? I get the following message when I run my if-then statement: ERROR 180-322: Statement is not valid or it is used out of proper order.
*libnames point to the folder that contains the datasets, not the individual datasets;
libname malawi '/folders/myfolders/';
*malawi is the name of the folders and mwfemale_pubuse is the name of the dataset;
proc contents data=malawi.mwfemale_pubuse;
*Age groups 13-17 and 18-24;
if 13 <= q2 <= 18 then agegroup= 1;
if 18 <= q2 <=24 then agegroup= 2;
Try this:
data want;
set malawi.mwfemale_pubuse;
if 13 <= q2 <= 18 then agegroup= 1;
if 18 <= q2 <=24 then agegroup= 2;
run;
Try this:
data want;
set malawi.mwfemale_pubuse;
if 13 <= q2 <= 18 then agegroup= 1;
if 18 <= q2 <=24 then agegroup= 2;
run;
Always end your PROC/DATA STEP with a RUN (or quit).
When creating new variables you need to explicitly tell SAS both what data set you're working with and what you're trying to create. This occurs within a DATA STEP.
DATA <New>;
SET <source>;
code to do stuff goes here - like if/then;
run;
I believe theres a free ecourse available as well as numerous videos here
Note: avoid making ambiguous age group definitions (as it is in your example for q2=18)
*Age groups 13-17 and 18-24;
if 13 <= q2 < 18 then agegroup= 1;
if 18 <= q2 <= 24 then agegroup= 2;
Thanks everyone!
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.