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 ;
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.