DATA Step, Macro, Functions and more

is it possible to import CSV file using DS2

Reply
New Contributor
Posts: 4

is it possible to import CSV file using DS2

 
Contributor
Posts: 33

Re: is it possible to import CSV file using DS2

As far as i know it is not possible to import files with ds2.

New Contributor
Posts: 4

Re: is it possible to import CSV file using DS2

So, Do you Know If Can I execute a SAS Tradicional Code in DS2?

 

Super User
Posts: 10,500

Re: is it possible to import CSV file using DS2

Please describe why you are unable to run "traditional" SAS code outside of DS2.

What type of code are you attempting?

New Contributor
Posts: 4

Re: is it possible to import CSV file using DS2

I have a problem with my SAS version, that not contains the JSON packages to parse a JSON file, so I built the code below in SAS traditional programming as a workaround. The code will be execute by SAS ESP.

 

	filename data '/sasdata/ma/mailing/ric4.json';

	data datatest (drop =  linha pos);
		infile data lrecl = 32000 truncover scanover dsd firstobs=2;

		Length linha $255.;

		Input Linha;

		campo    = trim(left(tranwrd(scan(linha,1,': '),'"','')));

		/*
		verificar se e uma informacao de data
		*/
		pos=index(linha,'_date');

		if pos = 0 then do;
		   conteudo = trim(left(tranwrd(tranwrd(scan(linha,-1,': '),'"',''),',','')));
		end;
	    else do;
 		   conteudo = trim(left(tranwrd(tranwrd(scan(linha,-2,'_date"'),'"',''),',','')));
		end;
	
	    if trim(left(campo)) not in ('[','{',']');

		grava = 0;
		grava =index(campo,'}');
	run;
Community Manager
Posts: 2,761

Re: is it possible to import CSV file using DS2

In SAS 9.4 M4 we have the JSON libname engine.  If you have that with your SAS ESP environment, that might be more robust.

New Contributor
Posts: 4

Re: is it possible to import CSV file using DS2

The JSON package are available from SAS 9.4 M3, the version that I using is SAS 9.4 M2.

Super User
Posts: 6,936

Re: is it possible to import CSV file using DS2

"Traditional" SAS code is run in a data step, as always.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Ask a Question
Discussion stats
  • 7 replies
  • 124 views
  • 0 likes
  • 5 in conversation