BookmarkSubscribeRSS Feed
SASstudentA
Calcite | Level 5

I am not getting any errors when running the following program, but when I try to assign my temp data sets, it keeps reading 0 observations and 4 variables, which is incorrect because my imported file has 4000 observations.  I am new to SAS and struggling, can anyone assist me?

Here is my SAS program:

 

options nodate nonumber;
proc import out = Project3
datafile = "C:\Users\A\Downloads\Project3.xlsx"
dbms=xlsx replace;
getnames=yes;
run;
%macro INST_NUM (inst1, inst2, inst3, inst4, inst5);
data temp;
set Project3;
if INST_NUM = '&inst1';

 

data temp1;
set temp;
if INST_NUM lt '5 AML';
x = ranuni (0);
output;
proc sort data = temp1;
by x;
run;
data one;
set temp1 (obs =5);

run;

 

data temp2;
set temp;
if INST_NUM lt '10 CML';
x = ranuni (0);
output;
proc sort data = temp2;
by x;
run;
data two;
set temp2 (obs=10);
run;


data temp3;
set temp;
if INST_NUM lt '20 ALL';
x = ranuni (0);
output;
proc sort data = temp3;
by x;
run;
data three;
set temp3 (obs=20);
run;


data temp4;
set temp;
if INST_NUM lt '5 CLL';
x = ranuni (0);
output;
proc sort data = temp4;
by x;
run;
data four;
set temp4 (obs=5);
run;


data &inst2;
set one two three four;
run;
data &inst3;
set one two three four;
run;
data &inst4;
set one two three four;
run;
data &inst5;
set one two three four;
run;

 

%mend INST_NUM;
%INST_NUM (1, new1_from_macro);
%INST_NUM (2, new2_from_macro);
%INST_NUM (3, new3_from_macro);
%INST_NUM (4, new4_from_macro);
%INST_NUM (5, new5_from_macro);

 

data newfrom_macro;
set new1_from_macro new2_from_macro new3_from_macro new4_from_macro new5_from_macro;
run;
proc print data = newfrom_macro;
title 'Tabulation of selected records from MACRO';
run;

 

AND here is my log info:

 

1282 options nodate nonumber;
1283 proc import out = Project3
1284 datafile = "C:\Users\A\Downloads\Project3.xlsx"
1285 dbms=xlsx replace;
1286 getnames=yes;
1287 run;

NOTE: The import data set has 4000 observations and 3 variables.
NOTE: WORK.PROJECT3 data set was successfully created.
NOTE: PROCEDURE IMPORT used (Total process time):
real time 0.14 seconds
cpu time 0.14 seconds


1288 %macro INST_NUM (inst1, inst2, inst3, inst4, inst5);
1289 data temp;
1290 set Project3;
1291 if INST_NUM = '&inst1';
1292 data temp1;
1293 set temp;
1294 if INST_NUM lt '5 AML';
1295 x = ranuni (0);
1296 output;
1297 proc sort data = temp1;
1298 by x;
1299 run;
1300 data one;
1301 set temp1 (obs =5);
1302
1303 data temp2;
1304 set temp;
1305 if INST_NUM lt '10 CML';
1306 x = ranuni (0);
1307 output;
1308 proc sort data = temp2;
1309 by x;
1310 run;
1311 data two;
1312 set temp2 (obs=10);
1313 run;
1314 data temp3;
1315 set temp;
1316 if INST_NUM lt '20 ALL';
1317 x = ranuni (0);
1318 output;
1319 proc sort data = temp3;
1320 by x;
1321 run;
1322 data three;
1323 set temp3 (obs=20);
1324 run;
1325 data temp4;
1326 set temp;
1327 if INST_NUM lt '5 CLL';
1328 x = ranuni (0);
1329 output;
1330 proc sort data = temp4;
1331 by x;
1332 run;
1333 data four;
1334 set temp4 (obs=5);
1335 run;
1336 data &inst2;
1337 set one two three four;
1338 run;
1339 data &inst3;
1340 set one two three four;
1341 run;
1342 data &inst4;
1343 set one two three four;
1344 run;
1345 data &inst5;
1346 set one two three four;
1347 run;
1348
1349 %mend INST_NUM;
1350 %INST_NUM (1, new1_from_macro);

NOTE: There were 4000 observations read from the data set WORK.PROJECT3.
NOTE: The data set WORK.TEMP has 0 observations and 3 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP.
NOTE: The data set WORK.TEMP1 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

 

NOTE: Input data set is empty.
NOTE: The data set WORK.TEMP1 has 0 observations and 4 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP1.
NOTE: The data set WORK.ONE has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP.
NOTE: The data set WORK.TEMP2 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

NOTE: Input data set is empty.
NOTE: The data set WORK.TEMP2 has 0 observations and 4 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP2.
NOTE: The data set WORK.TWO has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP.
NOTE: The data set WORK.TEMP3 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

 

NOTE: Input data set is empty.
NOTE: The data set WORK.TEMP3 has 0 observations and 4 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP3.
NOTE: The data set WORK.THREE has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP.
NOTE: The data set WORK.TEMP4 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

NOTE: Input data set is empty.
NOTE: The data set WORK.TEMP4 has 0 observations and 4 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP4.
NOTE: The data set WORK.FOUR has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

 

NOTE: There were 0 observations read from the data set WORK.ONE.
NOTE: There were 0 observations read from the data set WORK.TWO.
NOTE: There were 0 observations read from the data set WORK.THREE.
NOTE: There were 0 observations read from the data set WORK.FOUR.
NOTE: The data set WORK.NEW1_FROM_MACRO has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.03 seconds

 

NOTE: There were 0 observations read from the data set WORK.ONE.
NOTE: There were 0 observations read from the data set WORK.TWO.
NOTE: There were 0 observations read from the data set WORK.THREE.
NOTE: There were 0 observations read from the data set WORK.FOUR.
NOTE: The data set WORK.DATA241 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.ONE.
NOTE: There were 0 observations read from the data set WORK.TWO.
NOTE: There were 0 observations read from the data set WORK.THREE.
NOTE: There were 0 observations read from the data set WORK.FOUR.
NOTE: The data set WORK.DATA242 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.ONE.
NOTE: There were 0 observations read from the data set WORK.TWO.
NOTE: There were 0 observations read from the data set WORK.THREE.
NOTE: There were 0 observations read from the data set WORK.FOUR.
NOTE: The data set WORK.DATA243 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.01 seconds


1351 %INST_NUM (2, new2_from_macro);

NOTE: There were 4000 observations read from the data set WORK.PROJECT3.
NOTE: The data set WORK.TEMP has 0 observations and 3 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP.
NOTE: The data set WORK.TEMP1 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

NOTE: Input data set is empty.
NOTE: The data set WORK.TEMP1 has 0 observations and 4 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP1.
NOTE: The data set WORK.ONE has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP.
NOTE: The data set WORK.TEMP2 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

 

NOTE: Input data set is empty.
NOTE: The data set WORK.TEMP2 has 0 observations and 4 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP2.
NOTE: The data set WORK.TWO has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP.
NOTE: The data set WORK.TEMP3 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

NOTE: Input data set is empty.
NOTE: The data set WORK.TEMP3 has 0 observations and 4 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP3.
NOTE: The data set WORK.THREE has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP.
NOTE: The data set WORK.TEMP4 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

 

NOTE: Input data set is empty.
NOTE: The data set WORK.TEMP4 has 0 observations and 4 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP4.
NOTE: The data set WORK.FOUR has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

 

NOTE: There were 0 observations read from the data set WORK.ONE.
NOTE: There were 0 observations read from the data set WORK.TWO.
NOTE: There were 0 observations read from the data set WORK.THREE.
NOTE: There were 0 observations read from the data set WORK.FOUR.
NOTE: The data set WORK.NEW2_FROM_MACRO has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.03 seconds
cpu time 0.03 seconds

 

NOTE: There were 0 observations read from the data set WORK.ONE.
NOTE: There were 0 observations read from the data set WORK.TWO.
NOTE: There were 0 observations read from the data set WORK.THREE.
NOTE: There were 0 observations read from the data set WORK.FOUR.
NOTE: The data set WORK.DATA244 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.03 seconds

 

NOTE: There were 0 observations read from the data set WORK.ONE.
NOTE: There were 0 observations read from the data set WORK.TWO.
NOTE: There were 0 observations read from the data set WORK.THREE.
NOTE: There were 0 observations read from the data set WORK.FOUR.
NOTE: The data set WORK.DATA245 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.ONE.
NOTE: There were 0 observations read from the data set WORK.TWO.
NOTE: There were 0 observations read from the data set WORK.THREE.
NOTE: There were 0 observations read from the data set WORK.FOUR.
NOTE: The data set WORK.DATA246 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.01 seconds


1352 %INST_NUM (3, new3_from_macro);

NOTE: There were 4000 observations read from the data set WORK.PROJECT3.
NOTE: The data set WORK.TEMP has 0 observations and 3 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP.
NOTE: The data set WORK.TEMP1 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

NOTE: Input data set is empty.
NOTE: The data set WORK.TEMP1 has 0 observations and 4 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP1.
NOTE: The data set WORK.ONE has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP.
NOTE: The data set WORK.TEMP2 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.01 seconds

 

NOTE: Input data set is empty.
NOTE: The data set WORK.TEMP2 has 0 observations and 4 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP2.
NOTE: The data set WORK.TWO has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP.
NOTE: The data set WORK.TEMP3 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

 

NOTE: Input data set is empty.
NOTE: The data set WORK.TEMP3 has 0 observations and 4 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.02 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP3.
NOTE: The data set WORK.THREE has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP.
NOTE: The data set WORK.TEMP4 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

 

NOTE: Input data set is empty.
NOTE: The data set WORK.TEMP4 has 0 observations and 4 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP4.
NOTE: The data set WORK.FOUR has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.ONE.
NOTE: There were 0 observations read from the data set WORK.TWO.
NOTE: There were 0 observations read from the data set WORK.THREE.
NOTE: There were 0 observations read from the data set WORK.FOUR.
NOTE: The data set WORK.NEW3_FROM_MACRO has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.ONE.
NOTE: There were 0 observations read from the data set WORK.TWO.
NOTE: There were 0 observations read from the data set WORK.THREE.
NOTE: There were 0 observations read from the data set WORK.FOUR.
NOTE: The data set WORK.DATA247 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.00 seconds

 

NOTE: There were 0 observations read from the data set WORK.ONE.
NOTE: There were 0 observations read from the data set WORK.TWO.
NOTE: There were 0 observations read from the data set WORK.THREE.
NOTE: There were 0 observations read from the data set WORK.FOUR.
NOTE: The data set WORK.DATA248 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.00 seconds

 

NOTE: There were 0 observations read from the data set WORK.ONE.
NOTE: There were 0 observations read from the data set WORK.TWO.
NOTE: There were 0 observations read from the data set WORK.THREE.
NOTE: There were 0 observations read from the data set WORK.FOUR.
NOTE: The data set WORK.DATA249 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.00 seconds


1353 %INST_NUM (4, new4_from_macro);

NOTE: There were 4000 observations read from the data set WORK.PROJECT3.
NOTE: The data set WORK.TEMP has 0 observations and 3 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP.
NOTE: The data set WORK.TEMP1 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

 

NOTE: Input data set is empty.
NOTE: The data set WORK.TEMP1 has 0 observations and 4 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP1.
NOTE: The data set WORK.ONE has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP.
NOTE: The data set WORK.TEMP2 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

NOTE: Input data set is empty.
NOTE: The data set WORK.TEMP2 has 0 observations and 4 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP2.
NOTE: The data set WORK.TWO has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP.
NOTE: The data set WORK.TEMP3 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

NOTE: Input data set is empty.
NOTE: The data set WORK.TEMP3 has 0 observations and 4 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP3.
NOTE: The data set WORK.THREE has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP.
NOTE: The data set WORK.TEMP4 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

NOTE: Input data set is empty.
NOTE: The data set WORK.TEMP4 has 0 observations and 4 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP4.
NOTE: The data set WORK.FOUR has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.ONE.
NOTE: There were 0 observations read from the data set WORK.TWO.
NOTE: There were 0 observations read from the data set WORK.THREE.
NOTE: There were 0 observations read from the data set WORK.FOUR.
NOTE: The data set WORK.NEW4_FROM_MACRO has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.ONE.
NOTE: There were 0 observations read from the data set WORK.TWO.
NOTE: There were 0 observations read from the data set WORK.THREE.
NOTE: There were 0 observations read from the data set WORK.FOUR.
NOTE: The data set WORK.DATA250 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.00 seconds

 

NOTE: There were 0 observations read from the data set WORK.ONE.
NOTE: There were 0 observations read from the data set WORK.TWO.
NOTE: There were 0 observations read from the data set WORK.THREE.
NOTE: There were 0 observations read from the data set WORK.FOUR.
NOTE: The data set WORK.DATA251 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.ONE.
NOTE: There were 0 observations read from the data set WORK.TWO.
NOTE: There were 0 observations read from the data set WORK.THREE.
NOTE: There were 0 observations read from the data set WORK.FOUR.
NOTE: The data set WORK.DATA252 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.03 seconds


1354 %INST_NUM (5, new5_from_macro);

NOTE: There were 4000 observations read from the data set WORK.PROJECT3.
NOTE: The data set WORK.TEMP has 0 observations and 3 variables.
NOTE: DATA statement used (Total process time):
real time 0.03 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP.
NOTE: The data set WORK.TEMP1 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.00 seconds

 

NOTE: Input data set is empty.
NOTE: The data set WORK.TEMP1 has 0 observations and 4 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP1.
NOTE: The data set WORK.ONE has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP.
NOTE: The data set WORK.TEMP2 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.03 seconds

 

NOTE: Input data set is empty.
NOTE: The data set WORK.TEMP2 has 0 observations and 4 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP2.
NOTE: The data set WORK.TWO has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP.
NOTE: The data set WORK.TEMP3 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.00 seconds

 

NOTE: Input data set is empty.
NOTE: The data set WORK.TEMP3 has 0 observations and 4 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP3.
NOTE: The data set WORK.THREE has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP.
NOTE: The data set WORK.TEMP4 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

NOTE: Input data set is empty.
NOTE: The data set WORK.TEMP4 has 0 observations and 4 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP4.
NOTE: The data set WORK.FOUR has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

 

NOTE: There were 0 observations read from the data set WORK.ONE.
NOTE: There were 0 observations read from the data set WORK.TWO.
NOTE: There were 0 observations read from the data set WORK.THREE.
NOTE: There were 0 observations read from the data set WORK.FOUR.
NOTE: The data set WORK.NEW5_FROM_MACRO has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.ONE.
NOTE: There were 0 observations read from the data set WORK.TWO.
NOTE: There were 0 observations read from the data set WORK.THREE.
NOTE: There were 0 observations read from the data set WORK.FOUR.
NOTE: The data set WORK.DATA253 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.ONE.
NOTE: There were 0 observations read from the data set WORK.TWO.
NOTE: There were 0 observations read from the data set WORK.THREE.
NOTE: There were 0 observations read from the data set WORK.FOUR.
NOTE: The data set WORK.DATA254 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.ONE.
NOTE: There were 0 observations read from the data set WORK.TWO.
NOTE: There were 0 observations read from the data set WORK.THREE.
NOTE: There were 0 observations read from the data set WORK.FOUR.
NOTE: The data set WORK.DATA255 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds


1355
1356 data newfrom_macro;
1357 set new1_from_macro new2_from_macro new3_from_macro new4_from_macro new5_from_macro;
1358 run;

NOTE: There were 0 observations read from the data set WORK.NEW1_FROM_MACRO.
NOTE: There were 0 observations read from the data set WORK.NEW2_FROM_MACRO.
NOTE: There were 0 observations read from the data set WORK.NEW3_FROM_MACRO.
NOTE: There were 0 observations read from the data set WORK.NEW4_FROM_MACRO.
NOTE: There were 0 observations read from the data set WORK.NEW5_FROM_MACRO.
NOTE: The data set WORK.NEWFROM_MACRO has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.00 seconds


1359 proc print data = newfrom_macro;
1360 title 'Tabulation of selected records from MACRO';
1361 run;

NOTE: No observations in data set WORK.NEWFROM_MACRO.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds

 

14 REPLIES 14
PaigeMiller
Diamond | Level 26
if INST_NUM = '&inst1';

This will rarely if ever be true. The macro variable &inst1 must be in double quotes (not single quotes) if INST_NUM is a character variable, and it should not be in any kind of quotes in INST_NUM is numeric.

--
Paige Miller
SASstudentA
Calcite | Level 5
Thanks for the reply. I adjusted my statement to contain double quotes but
it did not have any effect on my output.
PaigeMiller
Diamond | Level 26

@SASstudentA wrote:
Thanks for the reply. I adjusted my statement to contain double quotes but
it did not have any effect on my output.

Please give us more information. Please don't be stingy with information.

 

Providing relevant parts of the SASLOG would be nice. Well, no "nice" is an understatement, it is mandatory.

 

Also, I said if the variable was NUMERIC, you don't use quotes. What type is this variable INST_NUM ??? What values does it contain??

 

--
Paige Miller
SASstudentA
Calcite | Level 5
The log is already included in my original post. It is below my SAS
program.

And the variable is a character variable, which is why I kept the quotes.

I was actually already aware of numeric variables having no quotes, and
character variables needing quotes, but I appreciate the assistance.
PaigeMiller
Diamond | Level 26

I do not see the log where you used double quotes instead of single quotes. And I would also request you run the program again, with the double quotes, and with the following option turned on before you run the macro.

 

options mprint;

Then show us the SASLOG of only the RELEVANT parts of the code, in other words the part of the data step where you replace the single quotes with the double quotes. Not the entire SASLOG, that is not what I am requesting.

 

Lastly, I asked you to state some of the values of this variable INST_NUM. This means you actually have to look at the data set after PROC IMPORT but before you run the macro and see what values INST_NUM contains. Tell us what a handful of the values are. Do you see INST_NUM anywhere has the value of the single character 1    ??? Because that is what your macro is looking for. If it never has the value of a single character 1 then you SHOULD get zero observations in your data set.

--
Paige Miller
Reeza
Super User
Does your code work without macros?
SASstudentA
Calcite | Level 5
Yes I know for sure that I can run the program without the macro, but I am
specifically trying to complete it using macro. It is a very large dataset
containing 4000 observations and 3 variables, so macro is apparently
supposed to be the most efficient (or so I'm told).
PaigeMiller
Diamond | Level 26

@SASstudentA wrote:
It is a very large dataset containing 4000 observations and 3 variables, so macro is apparently supposed to be the most efficient (or so I'm told).

Completely incorrect. (And 4000 is not large to most people)

--
Paige Miller
Reeza
Super User

We don't have any data so we cannot say if your logic is correct. If you fix one bug, that doesn't mean there aren't others so you'll have to show your new code and log each time.

 

However, from a skim of your program it looks like you're doing random selection of your data sets. PROC SURVEYSELECT is designed for exactly this and you probably don't need a macro at all. 

 


@SASstudentA wrote:

I am not getting any errors when running the following program, but when I try to assign my temp data sets, it keeps reading 0 observations and 4 variables, which is incorrect because my imported file has 4000 observations.  I am new to SAS and struggling, can anyone assist me?

Here is my SAS program:

 

options nodate nonumber;
proc import out = Project3
datafile = "C:\Users\A\Downloads\Project3.xlsx"
dbms=xlsx replace;
getnames=yes;
run;
%macro INST_NUM (inst1, inst2, inst3, inst4, inst5);
data temp;
set Project3;
if INST_NUM = '&inst1';

 

data temp1;
set temp;
if INST_NUM lt '5 AML';
x = ranuni (0);
output;
proc sort data = temp1;
by x;
run;
data one;
set temp1 (obs =5);

run;

 

data temp2;
set temp;
if INST_NUM lt '10 CML';
x = ranuni (0);
output;
proc sort data = temp2;
by x;
run;
data two;
set temp2 (obs=10);
run;


data temp3;
set temp;
if INST_NUM lt '20 ALL';
x = ranuni (0);
output;
proc sort data = temp3;
by x;
run;
data three;
set temp3 (obs=20);
run;


data temp4;
set temp;
if INST_NUM lt '5 CLL';
x = ranuni (0);
output;
proc sort data = temp4;
by x;
run;
data four;
set temp4 (obs=5);
run;


data &inst2;
set one two three four;
run;
data &inst3;
set one two three four;
run;
data &inst4;
set one two three four;
run;
data &inst5;
set one two three four;
run;

 

%mend INST_NUM;
%INST_NUM (1, new1_from_macro);
%INST_NUM (2, new2_from_macro);
%INST_NUM (3, new3_from_macro);
%INST_NUM (4, new4_from_macro);
%INST_NUM (5, new5_from_macro);

 

data newfrom_macro;
set new1_from_macro new2_from_macro new3_from_macro new4_from_macro new5_from_macro;
run;
proc print data = newfrom_macro;
title 'Tabulation of selected records from MACRO';
run;

 

AND here is my log info:

 

1282 options nodate nonumber;
1283 proc import out = Project3
1284 datafile = "C:\Users\A\Downloads\Project3.xlsx"
1285 dbms=xlsx replace;
1286 getnames=yes;
1287 run;

NOTE: The import data set has 4000 observations and 3 variables.
NOTE: WORK.PROJECT3 data set was successfully created.
NOTE: PROCEDURE IMPORT used (Total process time):
real time 0.14 seconds
cpu time 0.14 seconds


1288 %macro INST_NUM (inst1, inst2, inst3, inst4, inst5);
1289 data temp;
1290 set Project3;
1291 if INST_NUM = '&inst1';
1292 data temp1;
1293 set temp;
1294 if INST_NUM lt '5 AML';
1295 x = ranuni (0);
1296 output;
1297 proc sort data = temp1;
1298 by x;
1299 run;
1300 data one;
1301 set temp1 (obs =5);
1302
1303 data temp2;
1304 set temp;
1305 if INST_NUM lt '10 CML';
1306 x = ranuni (0);
1307 output;
1308 proc sort data = temp2;
1309 by x;
1310 run;
1311 data two;
1312 set temp2 (obs=10);
1313 run;
1314 data temp3;
1315 set temp;
1316 if INST_NUM lt '20 ALL';
1317 x = ranuni (0);
1318 output;
1319 proc sort data = temp3;
1320 by x;
1321 run;
1322 data three;
1323 set temp3 (obs=20);
1324 run;
1325 data temp4;
1326 set temp;
1327 if INST_NUM lt '5 CLL';
1328 x = ranuni (0);
1329 output;
1330 proc sort data = temp4;
1331 by x;
1332 run;
1333 data four;
1334 set temp4 (obs=5);
1335 run;
1336 data &inst2;
1337 set one two three four;
1338 run;
1339 data &inst3;
1340 set one two three four;
1341 run;
1342 data &inst4;
1343 set one two three four;
1344 run;
1345 data &inst5;
1346 set one two three four;
1347 run;
1348
1349 %mend INST_NUM;
1350 %INST_NUM (1, new1_from_macro);

NOTE: There were 4000 observations read from the data set WORK.PROJECT3.
NOTE: The data set WORK.TEMP has 0 observations and 3 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP.
NOTE: The data set WORK.TEMP1 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

 

NOTE: Input data set is empty.
NOTE: The data set WORK.TEMP1 has 0 observations and 4 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP1.
NOTE: The data set WORK.ONE has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP.
NOTE: The data set WORK.TEMP2 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

NOTE: Input data set is empty.
NOTE: The data set WORK.TEMP2 has 0 observations and 4 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP2.
NOTE: The data set WORK.TWO has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP.
NOTE: The data set WORK.TEMP3 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

 

NOTE: Input data set is empty.
NOTE: The data set WORK.TEMP3 has 0 observations and 4 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP3.
NOTE: The data set WORK.THREE has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP.
NOTE: The data set WORK.TEMP4 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

NOTE: Input data set is empty.
NOTE: The data set WORK.TEMP4 has 0 observations and 4 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP4.
NOTE: The data set WORK.FOUR has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

 

NOTE: There were 0 observations read from the data set WORK.ONE.
NOTE: There were 0 observations read from the data set WORK.TWO.
NOTE: There were 0 observations read from the data set WORK.THREE.
NOTE: There were 0 observations read from the data set WORK.FOUR.
NOTE: The data set WORK.NEW1_FROM_MACRO has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.03 seconds

 

NOTE: There were 0 observations read from the data set WORK.ONE.
NOTE: There were 0 observations read from the data set WORK.TWO.
NOTE: There were 0 observations read from the data set WORK.THREE.
NOTE: There were 0 observations read from the data set WORK.FOUR.
NOTE: The data set WORK.DATA241 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.ONE.
NOTE: There were 0 observations read from the data set WORK.TWO.
NOTE: There were 0 observations read from the data set WORK.THREE.
NOTE: There were 0 observations read from the data set WORK.FOUR.
NOTE: The data set WORK.DATA242 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.ONE.
NOTE: There were 0 observations read from the data set WORK.TWO.
NOTE: There were 0 observations read from the data set WORK.THREE.
NOTE: There were 0 observations read from the data set WORK.FOUR.
NOTE: The data set WORK.DATA243 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.01 seconds


1351 %INST_NUM (2, new2_from_macro);

NOTE: There were 4000 observations read from the data set WORK.PROJECT3.
NOTE: The data set WORK.TEMP has 0 observations and 3 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP.
NOTE: The data set WORK.TEMP1 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

NOTE: Input data set is empty.
NOTE: The data set WORK.TEMP1 has 0 observations and 4 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP1.
NOTE: The data set WORK.ONE has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP.
NOTE: The data set WORK.TEMP2 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

 

NOTE: Input data set is empty.
NOTE: The data set WORK.TEMP2 has 0 observations and 4 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP2.
NOTE: The data set WORK.TWO has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP.
NOTE: The data set WORK.TEMP3 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

NOTE: Input data set is empty.
NOTE: The data set WORK.TEMP3 has 0 observations and 4 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP3.
NOTE: The data set WORK.THREE has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP.
NOTE: The data set WORK.TEMP4 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

 

NOTE: Input data set is empty.
NOTE: The data set WORK.TEMP4 has 0 observations and 4 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP4.
NOTE: The data set WORK.FOUR has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

 

NOTE: There were 0 observations read from the data set WORK.ONE.
NOTE: There were 0 observations read from the data set WORK.TWO.
NOTE: There were 0 observations read from the data set WORK.THREE.
NOTE: There were 0 observations read from the data set WORK.FOUR.
NOTE: The data set WORK.NEW2_FROM_MACRO has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.03 seconds
cpu time 0.03 seconds

 

NOTE: There were 0 observations read from the data set WORK.ONE.
NOTE: There were 0 observations read from the data set WORK.TWO.
NOTE: There were 0 observations read from the data set WORK.THREE.
NOTE: There were 0 observations read from the data set WORK.FOUR.
NOTE: The data set WORK.DATA244 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.03 seconds

 

NOTE: There were 0 observations read from the data set WORK.ONE.
NOTE: There were 0 observations read from the data set WORK.TWO.
NOTE: There were 0 observations read from the data set WORK.THREE.
NOTE: There were 0 observations read from the data set WORK.FOUR.
NOTE: The data set WORK.DATA245 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.ONE.
NOTE: There were 0 observations read from the data set WORK.TWO.
NOTE: There were 0 observations read from the data set WORK.THREE.
NOTE: There were 0 observations read from the data set WORK.FOUR.
NOTE: The data set WORK.DATA246 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.01 seconds


1352 %INST_NUM (3, new3_from_macro);

NOTE: There were 4000 observations read from the data set WORK.PROJECT3.
NOTE: The data set WORK.TEMP has 0 observations and 3 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP.
NOTE: The data set WORK.TEMP1 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

NOTE: Input data set is empty.
NOTE: The data set WORK.TEMP1 has 0 observations and 4 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP1.
NOTE: The data set WORK.ONE has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP.
NOTE: The data set WORK.TEMP2 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.01 seconds

 

NOTE: Input data set is empty.
NOTE: The data set WORK.TEMP2 has 0 observations and 4 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP2.
NOTE: The data set WORK.TWO has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP.
NOTE: The data set WORK.TEMP3 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

 

NOTE: Input data set is empty.
NOTE: The data set WORK.TEMP3 has 0 observations and 4 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.02 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP3.
NOTE: The data set WORK.THREE has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP.
NOTE: The data set WORK.TEMP4 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

 

NOTE: Input data set is empty.
NOTE: The data set WORK.TEMP4 has 0 observations and 4 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP4.
NOTE: The data set WORK.FOUR has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.ONE.
NOTE: There were 0 observations read from the data set WORK.TWO.
NOTE: There were 0 observations read from the data set WORK.THREE.
NOTE: There were 0 observations read from the data set WORK.FOUR.
NOTE: The data set WORK.NEW3_FROM_MACRO has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.ONE.
NOTE: There were 0 observations read from the data set WORK.TWO.
NOTE: There were 0 observations read from the data set WORK.THREE.
NOTE: There were 0 observations read from the data set WORK.FOUR.
NOTE: The data set WORK.DATA247 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.00 seconds

 

NOTE: There were 0 observations read from the data set WORK.ONE.
NOTE: There were 0 observations read from the data set WORK.TWO.
NOTE: There were 0 observations read from the data set WORK.THREE.
NOTE: There were 0 observations read from the data set WORK.FOUR.
NOTE: The data set WORK.DATA248 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.00 seconds

 

NOTE: There were 0 observations read from the data set WORK.ONE.
NOTE: There were 0 observations read from the data set WORK.TWO.
NOTE: There were 0 observations read from the data set WORK.THREE.
NOTE: There were 0 observations read from the data set WORK.FOUR.
NOTE: The data set WORK.DATA249 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.00 seconds


1353 %INST_NUM (4, new4_from_macro);

NOTE: There were 4000 observations read from the data set WORK.PROJECT3.
NOTE: The data set WORK.TEMP has 0 observations and 3 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP.
NOTE: The data set WORK.TEMP1 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

 

NOTE: Input data set is empty.
NOTE: The data set WORK.TEMP1 has 0 observations and 4 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP1.
NOTE: The data set WORK.ONE has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP.
NOTE: The data set WORK.TEMP2 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

NOTE: Input data set is empty.
NOTE: The data set WORK.TEMP2 has 0 observations and 4 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP2.
NOTE: The data set WORK.TWO has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP.
NOTE: The data set WORK.TEMP3 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

NOTE: Input data set is empty.
NOTE: The data set WORK.TEMP3 has 0 observations and 4 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP3.
NOTE: The data set WORK.THREE has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP.
NOTE: The data set WORK.TEMP4 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

NOTE: Input data set is empty.
NOTE: The data set WORK.TEMP4 has 0 observations and 4 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP4.
NOTE: The data set WORK.FOUR has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.ONE.
NOTE: There were 0 observations read from the data set WORK.TWO.
NOTE: There were 0 observations read from the data set WORK.THREE.
NOTE: There were 0 observations read from the data set WORK.FOUR.
NOTE: The data set WORK.NEW4_FROM_MACRO has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.ONE.
NOTE: There were 0 observations read from the data set WORK.TWO.
NOTE: There were 0 observations read from the data set WORK.THREE.
NOTE: There were 0 observations read from the data set WORK.FOUR.
NOTE: The data set WORK.DATA250 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.00 seconds

 

NOTE: There were 0 observations read from the data set WORK.ONE.
NOTE: There were 0 observations read from the data set WORK.TWO.
NOTE: There were 0 observations read from the data set WORK.THREE.
NOTE: There were 0 observations read from the data set WORK.FOUR.
NOTE: The data set WORK.DATA251 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.ONE.
NOTE: There were 0 observations read from the data set WORK.TWO.
NOTE: There were 0 observations read from the data set WORK.THREE.
NOTE: There were 0 observations read from the data set WORK.FOUR.
NOTE: The data set WORK.DATA252 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.03 seconds


1354 %INST_NUM (5, new5_from_macro);

NOTE: There were 4000 observations read from the data set WORK.PROJECT3.
NOTE: The data set WORK.TEMP has 0 observations and 3 variables.
NOTE: DATA statement used (Total process time):
real time 0.03 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP.
NOTE: The data set WORK.TEMP1 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.00 seconds

 

NOTE: Input data set is empty.
NOTE: The data set WORK.TEMP1 has 0 observations and 4 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP1.
NOTE: The data set WORK.ONE has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP.
NOTE: The data set WORK.TEMP2 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.03 seconds

 

NOTE: Input data set is empty.
NOTE: The data set WORK.TEMP2 has 0 observations and 4 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP2.
NOTE: The data set WORK.TWO has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP.
NOTE: The data set WORK.TEMP3 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.00 seconds

 

NOTE: Input data set is empty.
NOTE: The data set WORK.TEMP3 has 0 observations and 4 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP3.
NOTE: The data set WORK.THREE has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP.
NOTE: The data set WORK.TEMP4 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

NOTE: Input data set is empty.
NOTE: The data set WORK.TEMP4 has 0 observations and 4 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.TEMP4.
NOTE: The data set WORK.FOUR has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

 

NOTE: There were 0 observations read from the data set WORK.ONE.
NOTE: There were 0 observations read from the data set WORK.TWO.
NOTE: There were 0 observations read from the data set WORK.THREE.
NOTE: There were 0 observations read from the data set WORK.FOUR.
NOTE: The data set WORK.NEW5_FROM_MACRO has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.ONE.
NOTE: There were 0 observations read from the data set WORK.TWO.
NOTE: There were 0 observations read from the data set WORK.THREE.
NOTE: There were 0 observations read from the data set WORK.FOUR.
NOTE: The data set WORK.DATA253 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.ONE.
NOTE: There were 0 observations read from the data set WORK.TWO.
NOTE: There were 0 observations read from the data set WORK.THREE.
NOTE: There were 0 observations read from the data set WORK.FOUR.
NOTE: The data set WORK.DATA254 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.01 seconds

 

NOTE: There were 0 observations read from the data set WORK.ONE.
NOTE: There were 0 observations read from the data set WORK.TWO.
NOTE: There were 0 observations read from the data set WORK.THREE.
NOTE: There were 0 observations read from the data set WORK.FOUR.
NOTE: The data set WORK.DATA255 has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds


1355
1356 data newfrom_macro;
1357 set new1_from_macro new2_from_macro new3_from_macro new4_from_macro new5_from_macro;
1358 run;

NOTE: There were 0 observations read from the data set WORK.NEW1_FROM_MACRO.
NOTE: There were 0 observations read from the data set WORK.NEW2_FROM_MACRO.
NOTE: There were 0 observations read from the data set WORK.NEW3_FROM_MACRO.
NOTE: There were 0 observations read from the data set WORK.NEW4_FROM_MACRO.
NOTE: There were 0 observations read from the data set WORK.NEW5_FROM_MACRO.
NOTE: The data set WORK.NEWFROM_MACRO has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.00 seconds


1359 proc print data = newfrom_macro;
1360 title 'Tabulation of selected records from MACRO';
1361 run;

NOTE: No observations in data set WORK.NEWFROM_MACRO.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds

 


 

 

Patrick
Opal | Level 21

To slightly re-formulate @Reeza's question: Does your program return the desired result if run without macros?

 

Looking into your code I could imagine that the string comparisons don't work the way you believe they do.

Can you please tell us if below sample code returns the result you're after? And if not then describe how your selection should work.

data sample;
  infile datalines truncover;
  input inst_num $10.;
  if INST_NUM lt '5 AML';
  datalines;
5 AML
10 CML
;
run;

Capture.JPG

ballardw
Super User

You define your macro:

%macro INST_NUM (inst1, inst2, inst3, inst4, inst5);

and then call it with

%INST_NUM (1, new1_from_macro);

So at least 3 parameters are not set. Any place inst3, inst4, inst5 are used they have no value to use. Unexpected results can results.

For instance

data &inst3;
set one two three four;
run;
data &inst4;
set one two three four;
run;
data &inst5;
set one two three four;
run;

would result in attempting to create data1 data2 and data3 the first time the macro runs because that is what SAS does with no actual data set name on a data step. Not to mention that all three of the sets would be identical...

 

 

Does your variable INST_NUM actually contain the value "1" with no other characters? Your other uses of INST_NUM place digits followed by other characters.

 

 

Text comparisons such as if INST_NUM lt '5 AML'; are very problematic. "10 CML" and "20 CLL" will be less than as character values are compared single character to single character left to right until there is a difference to determine "greater" or "less". So without knowing what your actual data contains you may not have any matches.

SASstudentA
Calcite | Level 5
The variables in excel for INST_NUM are as follows: Institute 1, Institute
2, Institute 3, Institute 4, and Institute 5.
Sorry, the instructions I have been given are very lacking to say the
least.
ballardw
Super User

@SASstudentA wrote:
The variables in excel for INST_NUM are as follows: Institute 1, Institute
2, Institute 3, Institute 4, and Institute 5.
Sorry, the instructions I have been given are very lacking to say the
least.

If you are looking to match "Institute 1" by looking at the macro variable &inst with a value of 1 then

 

if scan(Inst_num,2) = "&inst."; should work.

HOWEVER if you are saying "Institute 1" in place of a different text value then bets are off.

 

Currently you are attempting to match a single character "1" against something much longer. So of course nothing matches.

You have to know your data and what you want to consider "equal" or how to find. There are many functions in SAS that will search strings of characters for other strings and do things with them.

 

Other possible examples:

if findw(inst_num,"&inst.") > 0 then do...   FINDW uses typical word boundaries such as space, comma, period to tell if groups of characters are a "word". So this searches to see if the string "1" could be a word inside the value of inst_num. In this case it would not matter whether "1" came first, middle or end of a string but that it would be a "word" inside the string. If so the function returns the position in the string or 0 if not found.

 

The previous code with scan expects the "&inst" value to be exactly the second word.

FINDC, FIND and INDEX, INDEXC and INDEXW functions can also return information about whether a character, a string or a word contains given characters.

 

 

 

 

Reeza
Super User
I’m genuinely confused as to how your non macro code could work. Could you post the code that you know works? And you really should consider a non macro approach.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 14 replies
  • 1506 views
  • 3 likes
  • 5 in conversation