BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
dman1414
Fluorite | Level 6

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

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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 ;

View solution in original post

4 REPLIES 4
Tom
Super User Tom
Super User

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?

dman1414
Fluorite | Level 6

//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 ;

Tom
Super User Tom
Super User

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 ;
dman1414
Fluorite | Level 6
Thanks that resolved my issue.

SAS Innovate 2025: Call for Content

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!

Submit your idea!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 983 views
  • 0 likes
  • 2 in conversation