PROC DS2 code having error

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 119
Accepted Solution

PROC DS2 code having error

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

Accepted Solutions
Solution
‎02-22-2018 08:16 AM
Valued Guide
Posts: 525

Re: PROC DS2 code having error

Posted in reply to DeepakSwain

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


All Replies
PROC Star
Posts: 504

Re: PROC DS2 code having error

Posted in reply to DeepakSwain

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
Frequent Contributor
Posts: 119

Re: PROC DS2 code having error

Tried. Not working.
Swain
Super User
Posts: 13,358

Re: PROC DS2 code having error

Posted in reply to DeepakSwain

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.

Super User
Posts: 13,358

Re: PROC DS2 code having error

Posted in reply to DeepakSwain

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.

Valued Guide
Posts: 572

Re: PROC DS2 code having error

Posted in reply to DeepakSwain

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

Frequent Contributor
Posts: 119

Re: PROC DS2 code having error

[ Edited ]
Posted in reply to ChrisBrooks

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
Valued Guide
Posts: 572

Re: PROC DS2 code having error

Posted in reply to DeepakSwain

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 )

Solution
‎02-22-2018 08:16 AM
Valued Guide
Posts: 525

Re: PROC DS2 code having error

Posted in reply to DeepakSwain

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;
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 8 replies
  • 289 views
  • 5 likes
  • 5 in conversation