I'm new to SAS programming and I've created a CSV file from a Mainframe MXG report. The CSV file doesn't have column headings and I'm trying to figure out how to make that happen.
This is what the CSV file looks like:
ABC123ID;ICL226ID;DEF1234;STEP020;SYSC;12/12/2017;0.21;4.23
ABC123ID;ICL226ID;DFSRRC00;STEP010;SYSC;12/12/2017;57.61;1650.17
ABC123ID;CTRLIST;DEF1234;CONTROLR;SYSC;12/12/2017;0.29;1.10
I'd like it to look like this:
Jobname Procname Program Stepname System Date CPUTM Elapsed
ABC123ID;ICL226ID;DEF1234;STEP020;SYSC;12/12/2017;0.21;4.23
ABC123ID;ICL226ID;DFSRRC00;STEP010;SYSC;12/12/2017;57.61;1650.17
ABC123ID;CTRLIST;DEF1234;CONTROLR;SYSC;12/12/2017;0.29;1.10
Thanks
Simplest thing would be to just add a PUT statement that runs only once.
data _null_ ;
FILE DMAN1 DELIMITER =';' DSD ;
if _n_=1 then put 'System;CPUTMX;Program;Job;Date;Elapsed;ProcStep;Stepname';
set extract ;
put (system cputmx program job newdate elapsed procstep stepname)(+0) ;
run ;
How did you create the CSV file?
Also wouldn't you want the line with the column headers to also include commas between the values?
//RPT01 EXEC MXGSASV9
//PDB1 DD DSN=ABC.MXG.PDB.WEEKLY.G1150V00,DISP=SHR
//DMAN1 DD DISP=(,CATLG),DSN=TEST.ABCTESTA.CSV,
// RECFM=VB,LRECL=27000,BLKSIZE=0,SPACE=(CYL,(20,10),RLSE)
//SYSIN DD *
options nodsnferr nosource2 ;
data extract
(keep=system cputmx program job newdate
elapsed procstep stepname);
set pdb1.steps
;
format cputmx 9.2 ;
format elapsed 12.2 ;
format newdate DDMMYYS10.;
where substr(JOB,1,8) in ('ABC226ID');
cputmx = cputm ;
elapsed = selapstm ;
newdate = datepart(termtime);
Data _null_ ;
FILE DMAN1 DELIMITER =';' DROPOVER ;
set extract ;
put (_ALL_)(+0) ;
run ;
Simplest thing would be to just add a PUT statement that runs only once.
data _null_ ;
FILE DMAN1 DELIMITER =';' DSD ;
if _n_=1 then put 'System;CPUTMX;Program;Job;Date;Elapsed;ProcStep;Stepname';
set extract ;
put (system cputmx program job newdate elapsed procstep stepname)(+0) ;
run ;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.