sas - Defining a new field conditionally using put function with user-defined formats -
i trying define new value observation user defined format. however, if/then/else statement seems work observations year value of "2014". put statements not working other values. in sas, put statement blue in first statement, , black in other two. here picture of mean:
does know missing here? here complete code:
data claims_t03_group; set output.claims_t02_group; if year = "2014" test = put(compress(lookup,"_"),$g_14_prod35.); else if year = "2015" test = put(compress(lookup,"_"),$g_15_prod35.); else test = put(compress(lookup,"_"),$g_16_prod35.); run;
here example of mean when process seems "work" 2014:
as can see, when year value 2014, format lookup works correctly, , test field returns value expecting. however, years 2015 , 2016, test field returns lookup value without formatting.
your code utilises user-defined formats, $g_14_prod.
-$g_16_prod.
. guess there problem 1 or more of these, unless can provide format definitions difficult assist further.
try running following , sharing resulting output dataset work.prdfmts
:
proc sql noprint; select cats(libname,'.',memname) :myfmtlib sashelp.vcatalg objname = 'g_14_prod'; quit; proc format cntlout = prdfmts library=&myfmtlib; select g_14_prod g_15_prod g_16_prod; run;
n.b. assumes have 1 catalogue containing format name, , format definitions 3 formats contained in same catalogue. if not, need adapt bit , run once each format find , export definition.
Comments
Post a Comment