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

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,

 

 

Swain
1 ACCEPTED SOLUTION

Accepted Solutions
andreas_lds
Jade | Level 19

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;

View solution in original post

9 REPLIES 9
kiranv_
Rhodochrosite | Level 12

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
DeepakSwain
Pyrite | Level 9
Tried. Not working.
Swain
ballardw
Super User

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.

ballardw
Super User

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.

ChrisBrooks
Ammonite | Level 13

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.....

DeepakSwain
Pyrite | Level 9

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,

Swain
ChrisBrooks
Ammonite | Level 13

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 Smiley Happy )

andreas_lds
Jade | Level 19

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;
ashten28
Calcite | Level 5

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)

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
  • 9 replies
  • 2824 views
  • 5 likes
  • 6 in conversation