Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
711 views
in Technique[技术] by (71.8m points)

automatically convert SAS code to python?

A client needs to convert some SAS code to Python and the engagement lead has asked me if it was possible to do this automatically. I found some tools that purport to do this but I am very skeptical of any tool which claims to automatically convert from one programming language to another, let alone something as domain specific as SAS.

I have not seen the source code we need to convert yet but my guess is that these tools will do some simplistic keyword conversions but any moderately complex logic will require so much tweaking as to make it easier to just re-write from scratch manually. Seems to me to be a rabbit hole we want to avoid.

Any thoughts? How realistic is doing any kind of automatic code conversion even as an "accelerator" for manual work?

question from:https://stackoverflow.com/questions/65943845/automatically-convert-sas-code-to-python

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Not possible. I have spent a lot of time in this area and I have yet to see a tool be able to do a code conversion. Also, I don't think it is a good idea regardless. There are structures that do not translate between the 2 and also serious logical differences. For example, handle this in python (pseudocode):

data test (keep=x where=(y>3));   
   set test1 test2 (where=(z>6.2));
      by age gender;
   if age > "&ageMax.";
   blah blah;
run;

&ageMax is a macro created by a proc sql from a database. That query comes from a %include that has a bunch of database calls in it.

I have done SAS to C# conversions and you have to have someone versed in both. Look at one screen, code in the other.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...