stoping a code for input

Reply
Contributor
Posts: 45

stoping a code for input

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.

Attachment
Super User
Super User
Posts: 7,942

Re: stoping a code for input

Posted in reply to SVoldrich

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.

Contributor
Posts: 45

Re: stoping a code for input

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.

Super User
Super User
Posts: 7,942

Re: stoping a code for input

Posted in reply to SVoldrich

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.

Contributor
Posts: 45

Re: stoping a code for input

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.

Super User
Super User
Posts: 7,942

Re: stoping a code for input

Posted in reply to SVoldrich

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.:

data template;

     attrib col1-col100 format=best.;

     if _n_=0 then output;

run;

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 Smiley Happy

Occasional Contributor
Posts: 10

Re: stoping a code for input

Posted in reply to SVoldrich

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").

Occasional Contributor
Posts: 9

Re: stoping a code for input

Posted in reply to SVoldrich

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.

Anna

Super User
Posts: 5,500

Re: stoping a code for input

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;

run;

proc sql;

   select count(*) into : n_cms_vars

   from _contents_

   where upcase(name) = 'CMS_CODE';

quit;

%put n_cms_vars is &n_cms_vars;

Good luck.

Contributor
Posts: 45

Re: stoping a code for input

Posted in reply to Astounding

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!

Ask a Question
Discussion stats
  • 9 replies
  • 495 views
  • 3 likes
  • 5 in conversation