i have below kind of data that i like to put in dynamic proc format statement and use in JCL mainframe. pls help me how i can deal with it. appreciate your help in advance !
%%%BAT
%%%BBAT
%%%PRD
CICSP%
HXNDVR
NFSC
PODPRD
PROD
Q%%PFT%
Q%%PSC%
SAMA
SOFTBAT
SYSMAIN
Yes, the format creation is entirely separate from applying the format later. The format can be applied to many different data sets, and there is no way of predicting which mismatches will appear in a later data set.
If you are looking to determine matches and mismatches, then MERGE using in= variables is fairly straightforward for this purpose.
When you say dynamic, which part is dynamic? The data in the format or the JCL code? Could you please elaborate on what you are trying to accomplish?
There's still a little guesswork here about what you are trying to do. I think you could try:
(a) Create a file holding the data lines that you want in the format
(b) Mention that file in a DD statement
(c) Read in the file in the program, creating a SAS data set.
(d) Define the appropriate variables in the SAS data set so that it can be used as a CNTLIN= data set on PROC FORMAT.
Good luck.
here you go for my situation . pls help if anyone deal with this situation.
DATA _NULL_;
FILE INSTREAM NOPRINT LRECL=80 RECFM=FB; /* INSTREAM is my flat file defined in DD statement.
SET _LAST_ END=ABC;
IF _N_ = 1 THEN DO;
PUT "PROC FORMAT FMTLIB; " ;
PUT "VALUE $TSOID" ; (/* i am looking how i can define above %%% in the format, at this moment all is read as CHAR)
END;
PUT "'" RACFUSID "' = 'TSO'" ;
IF ABC EQ 1 THEN DO;
PUT "OTHER='.'" ;
PUT ';' ;
END;
Skip the part about how to program this, and focus on what the result should be. Suppose you had these three lines in your file:
CICSP%
HXNDVR
NFSC
What would your format look like. Is this it:
proc format;
value $TSOID 'CICSP%'='TSO' 'HXNDVR'='TSO' 'NFSC'='TSO' other=' ';
run;
The goal just isn't clear yet. So show us where you want to end up.
i want to create a format and save it for future use.
I like to match my existing format values with other dataset which will have similar kind of data. for example:
variable name=RACFUSID , it has below data. I will have another dataset which will have similar data but not necessary that all value will be same. I like to figure out which all values matches and which are missing. my worry is that if i use $ value in proc format now, it would read everything as CHAR and assign name e.g TSO (above). I am ok to have TSO name only for the values which are matching with next dataset but how about the missing values where other would not show me missing stuff as
CICSP%
HXNDVR
NFSC
Format implies that you have an existing value and want to display a different value, or in the case of invalue read as a different value.
So, in your case what is the start value and what is the result value?
DATA batst;
INFILE QLNAME;
INPUT NAME $8.;
PROC SORT NODUPS NODUPKEYS DATA=BATST;
BY name;
DATA _NULL_;
FILE INSTREAM NOPRINT LRECL=80 RECFM=FB;
SET _LAST_ END=ABC;
IF _N_ = 1 THEN DO;
PUT "PROC FORMAT FMTLIB; " ;
PUT "VALUE $TSOID" ;
END;
PUT "'" name "' = 'TSO'" ;
IF ABC EQ 1 THEN DO;
PUT "OTHER='.'" ;
PUT ';' ;
END;
DATA NEWDS;
SET BATST;
%INCLUDE INSTREAM;
RUN;
DATA bac;
SET DETAIL.abc01;
IF SYSID = 'SY';
TYPE = PUT(name,$TSOID.);
PROC SORT NODUPS NODUPKEYS DATA=BAc;
BY name;
--------------------------------------------
Here i want values which are matching with BAC dataset. I want which are missing also... the above e.g %%% values are really not existing in the BAC dataset but i couldnt figure out those in the current code. I have assign TSO for eveything which is available infile QLNAME howverev most of those are not available in the BAT BAC. I couldnt define indivisual format for every values as list is long .
I need to know if there is way to write a solution for it.
Instead of generating code which you then execute with an "%include" the "better" approach would be to create a control data set which you then pass into Proc Format via option "cntlin" as demonstrated in this example: https://support.sas.com/documentation/cdl/en/proc/68954/HTML/default/viewer.htm#n1e19y6lrektafn1kj6n...
If you want to store a format permanently then you need to store it in a permanent library, one which then is also available to other programs. Option "library" allows you to define the output library for the format (a libref must already exist).
Here are some of the pieces that will get you there. First, if you want to store the format permanently, you need a libname statement (no special features about it, a plain vanilla libname statement):
libname mylib 'path.to.some.dataset';
Next, begin as you did by reading in the data. However, call the variable START:
DATA batst;
INFILE QLNAME;
INPUT start $8.;
run;
PROC SORT NODUPKEY DATA=BATST;
BY start;
run;
Add a couple of additional variables that PROC FORMAT will want to see, to make it possible to use the SAS data set as input rather than requiring a VALUE statement:
data batst;
set batst end=done;
fmtname='$TSOID';
label='Found this one';
output;
if done;
hlo='O';
label='Not Found';
run;
Adding the extra variable with HLO=O will be used to create the OTHER= category by PROC FORMAT:
proc format cntlin=batst library=mylib;
run;
The library= option lets the format get saved permanently, and the cntlin= option tells PROC FORMAT to use the contents of the SAS data set to create the format.
That takes care of creating the format. But it doesn't make the format available to later programs. For that, you need to add instructions that tell SAS where to look for formats. For that part, take a look at documentation for the FMTSEARCH option.
You would use the format in a later step, possibly in this way:
result = put(varname, $TSOID.);
RESULT will either be "Found this one" or "Not Found" depending on whether or not there is a match.
Good luck.
it partially works actually, i did achieve that anyway. I have few values like %%%bat , %%%BBAT,%%%PRD etc.., this code label these all the values "FOUND" and when i pass the format into next dataset. i achieve the result for those values which exist in the dataset but not which are not matching with Qname dataset( such as %%%bat , %%%BBAT,%%%PRD )
I want these values %%%bat , %%%BBAT,%%%PRD as missing in the output.
------------------------------------------------------------
DATA QNAME;
INFILE QLNAME;
INPUT NAME $8.;
PROC SORT NODUPS NODUPKEYS DATA=QNAME;
BY NAME;
DATA DS;
SET QNAME END=LAST;
RETAIN FMTNAME '$HTNFMT';
START=NAME;
LABEL='FOUND';
OUTPUT;
IF LAST THEN DO;
HLO='O';
LABEL='NOT FOUND';
OUTPUT;
END;
RUN;
PROC FORMAT CNTLIN=DS;
PROC PRINT DATA=DS;
DATA NEW;
SET DETAIL.BATJOB01(KEEP=SYSID RACFUSID);
TYPE=PUT(RACFUSID,$HTNFMT.);
PROC SORT NODUPS NODUPKEYS DATA=NEW;
BY SYSID RACFUSID;
PROC PRINT DATA=NEW;
WHERE TYPE='FOUND';
. . . . . . . . . . . . . . . .
I'm glad you noticed that the second OUTPUT statement was needed.
You're only getting the "FOUND" records in your report because you requested that with this statement:
where type='FOUND';
If you want the "NOT FOUND" records as well, just remove the WHERE statement. Also notice, this statement should be added before LABEL='FOUND';
LENGTH LABEL $ 9;
Otherwise there won't be room to hold all the characters in "NOT FOUND". Finally, if you are printing the "NOT FOUND" records as well as the "FOUND" records, you might want TYPE to be the first variable in the BY statement in PROC SORT.
Good luck.
"NOT FOUND" values are only for DATA NEW dataset. NOT for DATA DS; I wanted to get value %%%BAT etc. as missing/NOT found.
probably need diffferent way to handle it.
Yes, the format creation is entirely separate from applying the format later. The format can be applied to many different data sets, and there is no way of predicting which mismatches will appear in a later data set.
If you are looking to determine matches and mismatches, then MERGE using in= variables is fairly straightforward for this purpose.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.