I am comparing App_address, Sup_address, Original_address and Current_address. I want to find if the title in all the four dataset is blank then 0 and if any one of the dataset have a title then flag it as 1. I am trying the below code but it is showing error. Can you please suggest?
data Title_comparison; set App_address Sup_address Original_address Current_address; if App_address: title ne "" or Sup_address: title ne "" or Original_address: title ne "" or Current_address: title ne "" then do; flag = 1; end; else flag = 0; run; Error log: 29 data Title_comparison; 30 set App_address Sup_address Original_address Current_address; 31 32 if App_address: title ne "" or Sup_address: title ne "" or Original_address: title ne "" or Current_address: title ne "" _ 22 76 32 ! then do; ERROR 22-322: Syntax error, expecting one of the following: <, <=, =, >, >=, EQ, GE, GT, IN, LE, LT, NE, NG, NL, NOTIN, ^=, ~=. ERROR 76-322: Syntax error, statement will be ignored. 33 flag = 1; 34 end; ___ 161 ERROR 161-185: No matching DO/SELECT statement. 35 else flag = 0; 36 run; NOTE: The SAS System stopped processing this step because of errors. WARNING: The data set WORK.TITLE_COMPARISON may be incomplete. When this step was stopped there were 0 observations and 32 variables.
Are you sure you need a SET statement?
You are vertically appending 4 datasets
(work.App_address , work.Sup_address , work.Original_address and work.Current_address).
If title is a variable name in all 4, you simply need :
if strip(title) NE '' then ... ;
But maybe you want to merge these datasets (horizontally) based on a key-variable (or multiple key-variables)?
And maybe you want to flag the observations that have the same key-combination and missing titles in all 4 datasets
Is this a ChatGpt or similar generated code?
The : list builder with variable names only works in a place where a list is acceptable such as an array definition, keep/drop list , format assignment or function like SUM or MEAN that will accept a list of variables.
So every use of : in this statement is illegal syntax and I am not sure what you thought it was attempting to do.
if App_address: title ne "" or Sup_address: title ne "" or Original_address: title ne "" or Current_address: title ne "" then do; flag = 1;
Are you trying to check if every variable in the data set App_address is doing something?
You really don't access anything related to a dataset name in the body of a data step. You can add a variable using the IN= option to indicate if an observation has a contribution from a dataset but once the variables on are in the data vector the actual data set name is moot.
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.
For SAS newbies, this video is a great way to get started. James Harroun walks through the process using SAS Studio for SAS OnDemand for Academics, but the same steps apply to any analytics project.
Find more tutorials on the SAS Users YouTube channel.