Hi,
I am running the below code by using call execute.
is any options to print the code to external file which is exceuted by below code.
Thank you,
Vivek.
Generic approach:
Add a FILE statement to the data step pointing to where you want to store the created program. Something like:
File "<your path goes here>\myprogramname.sas" ;
Replace CALL EXECUTE with PUT to create the text. Depending on the details of your actual CALL EXECUTE syntax this may mean creating a long character variable and assigning a value to that and then Put to the file.
With the picture you show, I would probably create several PUT statements instead of one for that call execute. But without Text to edit I can't provide an example.
After the data step creating the text file you would execute it with an %include statement when you want to run it.
%include "<your path goes here>\myprogramname.sas" ;
The path should start at a drive or mount point.
I would also suggest checking the results of creating the file by opening in an editor to make sure it contains what you expect.
Yikes.
You are running a data _NULL_ step already. So why not run a step to get the type of the variables listed your dataset added as variables in the data step and avoid having to use OPEN() and VARNUM() and VARTYPE()?
If you want to generate code to a file use the PUT statement. Then you can use all of the power of the PUT statement including formats. That will be much easier than your current code with STRIP() and IFC() function calls.
You can run the file using %INCLUDE.
Finally what is the code that are actually generate and run trying to do?
It looks like if you have multiple VARIABLE from the same DATASET you are going to generate a separate PROC SQL step for each one. You should be able to generate a single PROC SQL step for all datasets and a single SELECT statement for each DATASET.
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.
Ready to level-up your skills? Choose your own adventure.