Hi there,
I am trying to use proc DS2 for the first time. While converting base sas code to DS2 code, probably, I am doing some mistake and getting an error message: ERROR: General error ORA-12154: TNS:could not resolve the connect identifier specified
ERROR: TKTS initialization failed. I am sharing my sas code for your kind advice.
data test101;
input id name $;
datalines;
101 abc
102 def
103 ghi
104 jkl
105 mno
;
run;
proc ds2;
data test201/overwrite=yes;
method run();
dcl integer id, char name ;
set {select * from test101 where id =101};
end;
enddata;
run;
quit;
Thank you in advance for your kind reply.
Regards,
No problem running the code the following code on 9.04.01M3P062415, using the ds2-step provided by @ChrisBrooks
data test101; input id name $; datalines; 101 abc 102 def 103 ghi 104 jkl 105 mno ; run; proc ds2; data test201/overwrite=yes; method run(); dcl integer id; dcl char name ; set {select * from test101 where id =101}; end; enddata; run; quit; proc print data=work.test201;run; %put &=SYSVLONG;
I do not know much about DS2 but one thing odd i found is
char name
/*change it to any length you want*/
char(20) name
Proc DS2 wants to connect to a specified data source type. You need to specify a libname with the type of data connection.
From the online documentation example see the libname statement using the BASE engine description so Proc DS2 know that when you use that library it is a SAS data set.
libname MyFiles base 'C:\Myfiles'; proc ds2; data MyFiles.BaseTable; declare double j j2; method run(); do j = 1 to 1000; j2 = 2*j; output; end; end; enddata; run; quit; proc print data=myfiles.basetable (obs=10); run;
I get different errors running your code involving the comma in the dcl. I don't think declaring multiple data types in a single declare statement is valid.
I think the ORA-12154 is because for some reason DS2 thinks oracle is involved. Since you don't specify a library the connection to the library can't be found.
Proc DS2 wants to connect to a specified data source type. You need to specify a libname with the type of data connection.
From the online documentation example see the libname statement using the BASE engine description so Proc DS2 know that when you use that library it is a SAS data set.
libname MyFiles base 'C:\Myfiles'; proc ds2; data MyFiles.BaseTable; declare double j j2; method run(); do j = 1 to 1000; j2 = 2*j; output; end; end; enddata; run; quit; proc print data=myfiles.basetable (obs=10); run;
I get different errors running your code involving the comma in the dcl. I don't think declaring multiple data types in a single declare statement is valid.
I think the ORA-12154 is because for some reason DS2 thinks oracle is involved. Since you don't specify a library the connection to the library can't be found.
Firstly as @ballardw says you need two separate dcl statements for your variables - correcting that to the following runs fine for me
proc ds2;
data test201/overwrite=yes;
method run();
dcl integer id;
dcl char name ;
set {select * from test101 where id =101};
end;
enddata;
run;
quit;
One thing to note is that because you don't specify a length for the name variable it defaults to a char(8). It is, I believe good practice to ALWAYS declare a length for character variables.
The question remains as to why your getting an ORACLE error. I can only assume that something else must have occurred during your session to make SAS think it should be connecting to ORACLE but what that is I couldn't say.....
Hi there,
I think SAS 9.4 1M4 version supports PROC DS2 and I am having SAS 9.4 1M3. That may be the reason for the error.
Regards,
If I remember rightly Proc DS2 was in earlier versions than 9.4 1M4 but experimental (which in my experience meant it didn't work )
No problem running the code the following code on 9.04.01M3P062415, using the ds2-step provided by @ChrisBrooks
data test101; input id name $; datalines; 101 abc 102 def 103 ghi 104 jkl 105 mno ; run; proc ds2; data test201/overwrite=yes; method run(); dcl integer id; dcl char name ; set {select * from test101 where id =101}; end; enddata; run; quit; proc print data=work.test201;run; %put &=SYSVLONG;
Assigning a ODBC libname before calling PROC DS2 will cause the PROC DS2 to fail with error: "TKTS initialization failed"
Try de-assigning any ODBC libname before running the PROC DS2 (i.e: LIBNAME <libref> CLEAR)
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: