Scan a SAS scoring program for estimates

Accepted Solution Solved
Reply
SAS Employee
Posts: 13
Accepted Solution

Scan a SAS scoring program for estimates

Hi guys,

 

I'm in need of some quick input on something I'm working on.

I've received from a client some SAS score programs that contain the estimates of the models they're applying.

I don't have scoring data or any other information for that matter.

I would need to extract only those estimates without actually opening the programs and copy paste them.

The way to identify them is through this format:  array _beta_1_{2} _temporary_ ( -2.66877364579371       0.00004961821607);

Is there some kind of method/function to scan a sas program?

 

PS: I considered converting each sas program into a text file and then input it into a table, but that's a lot of data and it eats up resources.


Accepted Solutions
Solution
‎10-20-2016 04:37 AM
Super User
Posts: 10,552

Re: Scan a SAS scoring program for estimates

I'm somewhat confused about your concern about converting a SAS program to text. If the file is something like prog.sas then it is a text file.

 

And something like:

Data arraytext;
   infile "c:\path\*.sas" lrecl=2000;
   length Str $ 2000;
   input ;
   str=_infile_;
   if index(str,'array')>0;
run;

will pull all the lines from any .SAS files with the word array.(CASE SENSITIVE, so you may want to force case for the comparison).

 

View solution in original post


All Replies
Solution
‎10-20-2016 04:37 AM
Super User
Posts: 10,552

Re: Scan a SAS scoring program for estimates

I'm somewhat confused about your concern about converting a SAS program to text. If the file is something like prog.sas then it is a text file.

 

And something like:

Data arraytext;
   infile "c:\path\*.sas" lrecl=2000;
   length Str $ 2000;
   input ;
   str=_infile_;
   if index(str,'array')>0;
run;

will pull all the lines from any .SAS files with the word array.(CASE SENSITIVE, so you may want to force case for the comparison).

 

SAS Employee
Posts: 13

Re: Scan a SAS scoring program for estimates

At present time, converting the sas code into text and importing it into a table is a reasonable solution because I have an acceptable amount of scoring codes coming at a regular interval. (no more than 10 scoring codes per week). However, I do expect that in the future, this being a research centre that I'm working on, the department will develop and more data will have to be analyzed. That means that I might have hundreds of scoring codes, all with linear regression estimates inside, at a much more frequent pace. I worry this might be too much to handle with a text transformation. I was hoping this could be implemented with some sort of a function to extract only the rows I'm interested in, kind of like the SCAN function, but on a sas program. Thank you for the reply, It will be probably best to implement the text idea for now and research other stuff on the side.
Super User
Posts: 17,963

Re: Scan a SAS scoring program for estimates

As much as I love SAS, I wonder if this wouldn't be easier with a command line function? A GREP function somehow? I wouldn't know the exact solution but it may be worth looking into. 

SAS Employee
Posts: 13

Re: Scan a SAS scoring program for estimates

Thank you. I will try it out
Super User
Posts: 10,552

Re: Scan a SAS scoring program for estimates

Maybe creative use of creating data sets with the parameters when the procedure executes and then add in tracking information in a datastep or OUTSTAT data sets for scoring?

Super User
Posts: 17,963

Re: Scan a SAS scoring program for estimates

That does assume a regression type model. 

If the scoring code is for neural network or decision tree it may not make sense to get estimates. 

SAS Employee
Posts: 13

Re: Scan a SAS scoring program for estimates

Yes, the model is always going to be a linear regression because of the nature of the data.
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 7 replies
  • 347 views
  • 3 likes
  • 3 in conversation