BookmarkSubscribeRSS Feed
7 REPLIES 7
error_prone
Barite | Level 11

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

rickrp2
Calcite | Level 5

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

 

ballardw
Super User

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

What type of code are you attempting?

rickrp2
Calcite | Level 5

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;
ChrisHemedinger
Community Manager

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.

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
rickrp2
Calcite | Level 5

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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 7 replies
  • 1235 views
  • 0 likes
  • 5 in conversation