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)?
You never called the macro according to your log.
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
You never called the macro according to your log.
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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Get started using SAS Studio to write, run and debug your SAS programs.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.