BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Yegen
Pyrite | Level 9

My data is in .txt format and I have no problem running the following code using SAS on my PC. I have tried to modify the code so that I can use it on SAS Studio, but I am having an issue reading the data in. Please also see attached a subsample of my data. 

libname home '/home/utoronto/.../DEA/Data';
libname dea '/home/utoronto/.../DEA/Output';
options ps=max ls=140 nocenter;

%let _OutData='/home/utoronto/.../DEA/Data/ind1_out.txt';
%let _InData='/home/utoronto/.../DEA/Data/ind1_in.txt';
%let _nOutput=1;
%let _nInput=7;



%let _Orienta='InputMin';

%macro data;
data NY;
infile &_OutData delimiter='09'x missover dsd pad;
array NYarray(&_nOutput) $ NY1-NY&_nOutput;
length unitname $50 ;
input unitname $ NYarray(*) $;
if _n_ eq 1 then output;
drop unitname;
run;

data AY DMUs;
infile &_OutData delimiter='09'x missover dsd pad;
array AYarray(&_nOutput) AY1-AY&_nOutput;
length unitname $50;
input unitname $ AYarray(*);
if _n_ gt 1 then output;
run;

data NX;
infile &_InData delimiter='09'x missover dsd pad;
array NXarray(&_nInput) $ NX1-NX&_NInput;
length unitname $50;
input unitname $ NXarray(*) $;
if _n_ eq 1 then output;
drop unitname;
run;

data AX;
infile &_InData delimiter='09'x missover dsd pad;
array AXarray(&_nInput) AX1-AX&_nInput;
length unitname $50;
input unitname $ AXarray(*);
if _n_ gt 1 then output;
call symput('_nDmu',_n_-1);
run;

data DMUs; set AY (keep=unitname);
Uj0=_n_;
run;
%mend data;


Does anyone know why SAS Studio fails to run the above code (i.e., why can I not upload my data using the same code based on SAS 9.4)?  

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

You never called the macro according to your log. 

View solution in original post

3 REPLIES 3
Yegen
Pyrite | Level 9

Here is my log file: (it seems also odd that no data is created in the work folder)
 

 
 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 61         
 62         libname home '/home/utoronto/.../DEA/Data';
 NOTE: Libref HOME was successfully assigned as follows: 
       Engine:        V9 
       Physical Name: /home/utoronto/.../DEA/Data
 63         libname dea '/home/utoronto/.../DEA/Output';
 NOTE: Libref DEA was successfully assigned as follows: 
       Engine:        V9 
       Physical Name: /home/utoronto/.../DEA/Output
 64         options ps=max ls=140 nocenter;
 65         
 66         %let _OutData='/home/utoronto/.../DEA/Data/ind1_out.txt';
 67         %let _InData='/home/utoronto/.../DEA/Data/ind1_in.txt';
 68         %let _nOutput=1;
 69         %let _nInput=7;
 70         
 71         
 72         
 73         %let _Orienta='InputMin';
 74         
 75         %macro data;
 76            data NY;
 77               infile &_OutData delimiter='09'x missover dsd pad;
 78               array NYarray(&_nOutput) $ NY1-NY&_nOutput;
 79               length unitname  $50 ;
 80               input unitname $ NYarray(*) $;
 81               if _n_ eq 1 then output;
 82               drop unitname;
 83            run;
 84         
 85            data AY DMUs;
 86               infile &_OutData delimiter='09'x missover dsd pad;
 87               array AYarray(&_nOutput) AY1-AY&_nOutput;
 88               length unitname  $50;
 89               input unitname $ AYarray(*);
 90               if _n_ gt 1 then output;
 91            run;
 92         
 93            data NX;
 94               infile &_InData delimiter='09'x missover dsd pad;
 95               array NXarray(&_nInput) $ NX1-NX&_NInput;
 96               length unitname  $50;
 97               input unitname $ NXarray(*) $;
 98               if _n_ eq 1 then output;
 99               drop unitname;
 100           run;
 101        
 102           data AX;
 103              infile &_InData delimiter='09'x missover dsd pad;
 104              array AXarray(&_nInput) AX1-AX&_nInput;
 105              length unitname  $50;
 106              input unitname $ AXarray(*);
 107              if _n_ gt 1 then output;
 108              call symput('_nDmu',_n_-1);
 109           run;
 110        
 111           data DMUs; set AY (keep=unitname);
 112              Uj0=_n_;
 113           run;
 114        %mend data;
 115        
 116        
 117        
 118        OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 131        
Reeza
Super User

You never called the macro according to your log. 

Yegen
Pyrite | Level 9

You are 100% right, @Reeza. That was probably causing the error. I have made a modification by taking out the macro and now the code works.

%let _InData="/home/utoronto/.../DEA/Data/ind1_in.txt" ;
%let _nInput=7;
%let _OutData="/home/utoronto/.../DEA/Data/ind1_out.txt" ;
%let _nOutput=1;
%let _Orienta='InputMin';

libname sasdea "/home/utoronto/.../DEA/";
proc datasets nolist; delete Eff Report1
report2; run;

data NY;
     infile &_OutData delimiter='09'X missover dsd ;
     array NYarray(&_nOutput) $ NY1- NY&_nOutput ;
length unitname $ 50 ;
input unitname $ NYarray(*) $	;
if  _n_ eq 1 then output	;
drop unitname;
run;

data AY DMUs;
     infile &_OutData delimiter='09'X missover dsd;
array AYarray(&_nOutput) AY1-AY&_nOutput;
length unitname $ 50 ;
input unitname  $ AYarray(*) ;
if _n_ gt 1 then output  ;
run;

data NX;
     infile &_InData delimiter='09'X missover dsd ;
array NXarray(&_nInput)$ NX1-NX&_NInput ;
length unitname $ 50 ;
input unitname $ NXarray(*) $	;
if _n_ eq 1 then output;
drop unitname;
run;

data AX;
     infile &_InData  delimiter='09'X missover dsd ;
array AXarray(&_nInput) AX1-AX&_nInput;
length unitname $ 50 ;
input unitname $ AXarray(*)	;
if _n_ gt 1 then output;
call symput('_nDmu',_n_-1);
run;

data DMUs;
set AY (keep=UnitName); Uj0=_n_;
run;

Thanks for pointing out this silly mistake. 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 1113 views
  • 1 like
  • 2 in conversation