05-15-2014 10:56 AM
Is there a way to stop the code so that it waits for your input, and then have it start up again?
My husband is a photographer and has created actions in Photoshop where he pushes a button and the action runs to a certain point, then stops, he makes the adjustment specific to the image he is working on then it continues and finishes the action.
Is there a way to do something like this in SAS?
My thought is that I have it run, stop just after i do the proc transpose, and describe table (to know how many fields i'm combining) let me made the adjustment to the code in the CATX part of my next string of code, and then continue on to finish the program.
05-15-2014 10:59 AM
As far as I know there is not stop start mechanism as such. You could create a WINDOW, and on that ask for some feedback and use that in your program, however you cant really modify you code at that point. I would ask why you need to do this however. Why not just highlight code and submit it piece by piece, e.g. highlight up to and including the transpose, submit that. Now look at the results and modify/run other code.
05-15-2014 11:04 AM
i'm trying to automate it as much as possible, so that in my absense, some one who hasn't run the code before or isn't familiar with the project, can run it without having to dig through the code to know where to stop it and make an adjustment.
05-15-2014 11:23 AM
I can't see how you would automate something like that. If the other person can't work out what to change from documentation + source code then you would need to build some kind of parameter entry screen, SCL/AF perhaps. I wouldn't recommend it though. Perhaps you could post the bit of code you are worried about I could have a look tomorrow, however I do feel that documentation is really the way forward there. Good code should be readable and self explanatory (or where not, then documented well) so that anyon can pick it up and run with it.
05-15-2014 11:39 AM
guess i'm not so much worried about them not being able to read it... also worried that *I* will forget to change that one piece next year when it's been a year since I last looked at it or thought about it.
There has to be a way....
attaching an example of what I want to the original.
05-15-2014 01:09 PM
Well, there are a variety of programming techniques to avoid hardcoding into your program. Kanna mentioned: proc sql; select distinct into :mvar from xx;quit; and use that. Here are some other ideas:
Create a template dataset which contains far more items than you will get, e.g.:
attrib col1-col100 format=best.;
if _n_=0 then output;
Then if you set the above with the transposed table, you know there will always be 100 columns even with no data, and can program for that.
Another method is to generate code based off the transposed data, using call execute.
One final example is to not transpose at all. As you are transposing, I assume the data is normalised, hence just program based off a long table rather than a wide table. E.g. for stats use proc sql, sum, min max etc.
And if your worried about forgetting, add comments! Again documentation
05-15-2014 12:30 PM
If your concern is project management (hand-off, maintenance), then I'd suggest using Enterprise Guide. Features like prompts, process flows, and ordered lists are really designed to help manage projects as a whole. It seems like much of what you're requesting could be addressed there.
I like using Display Manager for coding, but will usually port projects to Enterprise Guide for the very reasons you mention. Even if there's a document that spells out "run X, then run Y, then change Z", it's prone to human error and forgetfulness. A project might give the structure you're looking for and allow you to express the process in a more concrete way ("import photo", "make adjustment").
05-15-2014 11:56 AM
You can count the maximum occurance of the CMS codes per ID before the transpose, and create a macro variable to use it later, see http://support.sas.com/resources/papers/proceedings13/198-2013.pdf
Use PUT to create a text version of that number or any number in between, and concatenate it to the end of your "CMS_Code_ " as n in CMS_Code_n or better CMS_Code_nn if you need to enlist your unknown variables later.
Once your macro variable with the max value is created, you can dynamically use it without the need to stop the program.
I hope this helps.
05-15-2014 01:20 PM
Kanna has the right general idea. If you were to learn macro language (or find someone who knows it), you would not have to stop the program at all. You could let the program count the number of CMS_Code variables created by PROC TRANSPOSE, and have the program automatically adjust the subsequent SQL step with no human intervention required.
This could be a piece of the puzzle to get you started:
proc contents data=output_from_proc_transpose out=_contents_ (keep=name) noprint;
select count(*) into : n_cms_vars
where upcase(name) = 'CMS_CODE';
%put n_cms_vars is &n_cms_vars;
06-27-2014 12:35 PM
I ended up completing the project while stoping the code manually, and changing the info, and restarting... it's just that it takes 6 hrs to pull all the data... and i wanted this to run overnight with little to no intervention so i can get in the morning and move on to the next task and not have my system tied up all day waiting for this to run and constantly paying attention to it to make sure i'm inputting stuff as needed.
I now have a little bit of downtime and thought I would circle back to this to see if I could figure it out.
Astounding, this just might be what i was looking for.
most of that code is still foreign to me (only been using SAS for about 10 months, no prior coding/SQL experience). Especially the last bit of code - the proc sql sleect count. I think i understand what it's supposed to do... but i can't get it to do it...
But thank you for the response.
I will play with this! Fingers crossed!