- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello
Let's say I am building today a logistic regression model (PD credit risk model).
Then I want to score a new data in the future.
This is the code how to do it.
My question-
Let's say that the new data will be available in the future.
Then I don't want to run again the model, but I want to use the model that I build today.
The code -store MyModel; keep the model in WORK library
How can I keep it in a permanent library that in future I can use it?
If I create a library called R_R then - can I use code- store R_R.MyModel ???
data raw_tbl;
input sex $ age flag@@;
cards;
Female 35 0 Male 44 0
Male 45 1 Female 47 1
Female 51 0 Female 47 0
Male 54 1 Male 47 1
Female 35 0 Female 34 0
Female 48 0 Female 56 1
Male 46 1 Female 59 1
Female 46 1 Male 59 1
Male 38 1 Female 39 0
Male 49 1 Male 42 1
Male 50 1 Female 45 0
Female 47 0 Female 30 1
Female 39 0 Female 51 0
Female 45 0 Female 43 1
Male 39 1 Male 31 0
Female 39 0 Male 34 0
Female 52 1 Female 46 0
Male 58 1 Female 50 1
Female 32 0 Female 52 1
Female 35 0 Female 51 0
;
Run;
data test_tbl;
input sex $ age;
cards;
Female 35
Male 19
Male 70
;
run;
proc format;
value Dependent_Fmt
1 = 'Default'
0 = 'Non_Default';
run;
proc genmod data=raw_tbl namelen=60 descending ;
class sex;
model Flag=sex age/ dist=binomial link=logit type3 wald ;
store MyModel;
output out=row_data_with_predict p=P_subscibe xbeta=logit;
run;
/**Create data set row_data_with_predict that have row data with predict colmn called :P_subscibe***/
/***Show the coefficients in a data set***/
proc plm source=MyModel;
show parameters;
run;
/**score new data set****/
proc plm restore=MyModel;
score data=test_tbl out=test_out_tbl predicted / ilink;
run;
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
As ballardw said ,assign a new LIBNAME to store it.
1) Store this binary file under path "c:\temp\":
libname x v9 'c:\temp\'; proc genmod data=raw_tbl namelen=60 descending ; class sex; model Flag=sex age/ dist=binomial link=logit type3 wald ; store x.MyModel; output out=row_data_with_predict p=P_subscibe xbeta=logit; run;
2) Score a new dataset:
data test_tbl; input sex $ age; cards; Female 35 Male 19 Male 70 ; run; libname x v9 'c:\temp\'; /**score new data set****/ proc plm restore=x.MyModel; score data=test_tbl out=test_out_tbl predicted / ilink; run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Did you try using a libname.<store> name structure with the Store statement?
Like
store somelib.MyModel;
to place the store into to Somelib library?
Standard SAS naming rules apply to all the "special" output sets if not given a library in the statement creating them they get written to the Work library. Provide the library in the name when created.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
As ballardw said ,assign a new LIBNAME to store it.
1) Store this binary file under path "c:\temp\":
libname x v9 'c:\temp\'; proc genmod data=raw_tbl namelen=60 descending ; class sex; model Flag=sex age/ dist=binomial link=logit type3 wald ; store x.MyModel; output out=row_data_with_predict p=P_subscibe xbeta=logit; run;
2) Score a new dataset:
data test_tbl; input sex $ age; cards; Female 35 Male 19 Male 70 ; run; libname x v9 'c:\temp\'; /**score new data set****/ proc plm restore=x.MyModel; score data=test_tbl out=test_out_tbl predicted / ilink; run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Perfect,
Only 2 questions please-
in your code libname x v9 'c:\temp\';
the name of permanent library is X
What is V9?? Why should you write V9?
Can I save in library X also normal data sets or it is only to save binary files?
What does it mean binary file? as i understand the binary file doesn't look like a normal data set?
IS the binary file is a SAS data set file? Is it a sas file?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
V9 is default engine of libname statement, you can ignore it . like:
libname x 'c:\temp\';
"Can I save in library X also normal data sets or it is only to save binary files?"
Yes. Could save both dataset and binary file.
"What does it mean binary file? "
It is your model save file -- x.MyModel
"IS the binary file is a SAS data set file? Is it a sas file?"
It is a specical sas file for saving model .
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@Ronein wrote:
I wonder why is it called binary file? Binary is 1/0.
Binary files can also refer to those not intended to be "read" by people directly. Technically all computer files are "binary" in that they are codes that resolve to 1/0 at some level, look at things like ASCII binary values for example. Open any file ending in EXE or DLL with a text editor as an example of what a "binary file" is going to look like in general.
The files will contain things that won't make linguistic sense generally when displayed using any of the text display encodings such as ASCII, UTF, EBCDIC. You might find some strings that make sense but don't count on it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
It is an uneditable file.
If you want more , reach out the sas Technology Support.
https://support.sas.com/