Piece of code on Unix Server is not working, but works on PC SAS. When executed in UNIX SAS, the output datasets pc_pf_yes_1 and pc_pf_no_1 both have 0 observations, but no error is observed. In PC SAS, the code works fine and populates the datasets as intended.
The below datastep is within a macro.
data pc_pf_yes_1 pc_pf_no_1;
set pc_&month._2;
if primary_flag = "Y" then output pc_pf_yes_1;
else if primary_flag = "N" then output pc_pf_no_1;
run;
primary_flag is a binary variable with values Y and N, stored as a string length 1. &month. is a macro variable that stores a month name for data selection.
Is there a quirk with UNIX SAS within a macro that I don't know about?
Check the data. If the value of primary_flag has leading spaces or is lower case then it will not match either 'Y' or 'N'. Note that trailing spaces do not matter. To see the leading spaces try printing the variable with the $QUOTE.
format.
If you read the data from a text file then primary_flag might have a carriage return on the end of it, which is also hard to see in normal print outs. On a PC the carriage return is part of the end of line marker, but Unix just uses line feed as the end of line marker so the carriage return can end up in the data. Use the TERMSTR=CRLF option on the INFILE statement. Or you can use compress(primary_flag,'0d'x)
to remove carriage return characters. To see these and other hidden characters you can print the data using $HEX.
format. Or use the LINE
statement in the data step that reads the text file.