BookmarkSubscribeRSS Feed
jl1005
Obsidian | Level 7

Hi Rick,

 

I know its been a few weeks, but I've had an error pop up that I can't figure out why. Here's the code:

proc iml;
dsNames = cats("&home_team","_H_",'class_1':'class_10'); /*Read in home team matrices */
MatNames = dsNames;
do i = 1 to ncol(dsNames);
		use (dsNames[i]);
			read all var _ALL_ into X;		
			tmp = X;
			X = j(nrow(X) + 8, ncol(X), 0);
			rows = setdif(1:nrow(X), do(4,32,4));
			X[rows, ] = tmp;
			print X;
			call valset(MatNames[i], X);
			close (dsNames[i]);
end;
	free X rows tmp dsNames MatNames;
dsNames = cats("&away_team","_a_",'class_1':'class_10'); /*Read in away team matrices */
MatNames = dsNames;
do i = 1 to ncol(dsNames);
		use (dsNames[i]);
			read all var _ALL_ into X;		
			tmp = X;
			X = j(nrow(X) + 8, ncol(X), 0);
			rows = setdif(1:nrow(X), do(4,32,4));
			[rows, ] = tmp;
			print X;
			call valset(MatNames[i], X);
			close (dsNames[i]);
end;

I thought maybe the free statement would help, but it hasn't made a difference. Here's the error, then the rest of the code

1          ;*';*";*/;quit;run;
2          OPTIONS PAGENO=MIN;
3          %LET _CLIENTTASKLABEL='final home and away sim';
4          %LET _CLIENTPROCESSFLOWNAME='Process Flow (3)';
5          %LET _CLIENTPROJECTPATH='C:\Users\jblon\Documents\My SAS Files\baseball_3.egp';
6          %LET _CLIENTPROJECTPATHHOST='DESKTOP-BLJ64FN';
7          %LET _CLIENTPROJECTNAME='baseball_3.egp';
8          %LET _SASPROGRAMFILE='C:\Users\jblon\Documents\My SAS Files\9.4\final home and away sim.sas';
9          %LET _SASPROGRAMFILEHOST='DESKTOP-BLJ64FN';
10         
11         ODS _ALL_ CLOSE;
12         OPTIONS DEV=ACTIVEX;
13         FILENAME EGSR TEMP;
14         ODS tagsets.sasreport13(ID=EGSR) FILE=EGSR
15             STYLE=HtmlBlue
16             STYLESHEET=(URL="file:///C:/Program%20Files/SASHome/SASEnterpriseGuide/7.1/Styles/HtmlBlue.css")
17             NOGTITLE
18             NOGFOOTNOTE
19             GPATH=&sasworklocation
20             ENCODING=UTF8
21             options(rolap="on")
22         ;
NOTE: Writing TAGSETS.SASREPORT13(EGSR) Body file: EGSR
23         


24         proc iml;
NOTE: IML Ready
25         dsNames = cats("&home_team","_H_",'class_1':'class_10');
25       !                                                          /*Read in home team matrices */
26         MatNames = dsNames;
27         do i = 1 to ncol(dsNames);
28         		
28       !   use (dsNames[i]);
29         			
29       !    read all var _ALL_ into X;
29       !                              		
30         			
30       !    tmp = X;
31         			
31       !    X = j(nrow(X) + 8, ncol(X), 0);
32         			
32       !    rows = setdif(1:nrow(X), do(4,32,4));
33         			
33       !    X[rows, ] = tmp;
34         			
34       !    print X;
35         			
35       !    call valset(MatNames[i], X);
36         			
36       !    close (dsNames[i]);
37         end;
38         	
38       !  free X rows tmp dsNames MatNames;
39         dsNames = cats("&away_team","_a_",'class_1':'class_10');
39       !                                                          /*Read in away team matrices */
40         MatNames = dsNames;
41         do i = 1 to ncol(dsNames);
2                                                          The SAS System                             22:35 Thursday, April 20, 2017

42         		
42       !   use (dsNames[i]);
43         			
43       !    read all var _ALL_ into X;
43       !                              		
44         			
44       !    tmp = X;
45         			
45       !    X = j(nrow(X) + 8, ncol(X), 0);
46         			
46       !    rows = setdif(1:nrow(X), do(4,32,4));
47         			
47       !    [rows, ] = tmp;
              _
              180
ERROR 180-322: Statement is not valid or it is used out of proper order.

48         			
48       !    print X;
49         			
49       !    call valset(MatNames[i], X);
50         			
50       !    close (dsNames[i]);
51         end;
ERROR: END does not occur within DO group at line=51 col=1.
52         
53         %LET _CLIENTTASKLABEL=;
54         %LET _CLIENTPROCESSFLOWNAME=;
55         %LET _CLIENTPROJECTPATH=;
56         %LET _CLIENTPROJECTPATHHOST=;
57         %LET _CLIENTPROJECTNAME=;
58         %LET _SASPROGRAMFILE=;
59         %LET _SASPROGRAMFILEHOST=;
60         
61         ;*';*";*/;quit;
NOTE: Exiting IML.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE IML used (Total process time):
      real time           1.25 seconds
      cpu time            0.86 seconds
      
61       !                run;
62         ODS _ALL_ CLOSE;
63         
64         
65         QUIT; RUN;
66         

So the first block of code to read in the first set of datasets is running fine, but then it has an error when it goes to read in the second set. Any suggestions?

 

Thank you.

1 REPLY 1
jl1005
Obsidian | Level 7

I think I figured it out, the second block of code was missing the X in front of X[rows, ].

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.

From The DO Loop
Want more? Visit our blog for more articles like these.
Discussion stats
  • 1 reply
  • 674 views
  • 0 likes
  • 1 in conversation