BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi All

How do we output a heading for each column in the data - I am using MVS on the mainframe with SAS - I can write out the data, but need to be heading labels for each of the columns.

Regards
Shelton.
5 REPLIES 5
Cynthia_sas
SAS Super FREQ
Hi:
Not sure what you mean. Are you using PROC PRINT, PROC REPORT, DATA _NULL_? Are you sending output to the LISTING destination (in a mainframe job, this would be the equivalent of the SYSOUT DD location)? How are you "writing out the data"?

Can you post an example of your code?? Refer to this posting for more information about how to post code and maintain the indentation of the code.
http://support.sas.com/forums/thread.jspa?messageID=27609毙

cynthia
deleted_user
Not applicable
Basically what I want to do is output the data to a dataset but also have the field labels appear at the top of the output - like

PartNo Description Price
XXXX somepartx $110.00
YYY someparty $55.00


etc etc
This is what my code looks like now:

[pre]DATA PUTOUT;
SET STOCK;
FILE OUTF1;
PUT @1 PART $12.
@13 DESC $10.
@40 PRICE 8.2;
[/pre]
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Given your coded approach, you will need to add a single-line PUT statement to generate a HEADER row. Your DATA step code needs to test for IF _N_=1 and issue a PUT with a text-character row surrounded with double-quotes and commas, most likely. Here's an example:

IF _N_=1 THEN PUT '"VAR1","VAR2","VAR3"';

Of course you may also want to consider the "ODS CSV" approach and use PROC PRINT.

Suggest you search the SAS support http://support.sas.com/ website for ODS CSV examples if that's your alternate approach.


Scott Barry
SBBWorks, Inc.
deleted_user
Not applicable
Hi Scott

Thanks for the reply - it worked! I didnt want to use ODS as I have used that previously to create a HTML output file. I thought there was an easier way to do this.

This is my code:

DATA PUTOUT;
SET STOCK;
FILE OUTF1;
IF _N_=1 THEN PUT
@01 "PARTNO"
@13 "MONTHIND"
@40 "YEARIND"
;
PUT @1 PART $12.
@13 MONTHIND $1.
@40 YEARIND $1.;

Thanks again.
Shelton.
data_null__
Jade | Level 19
There are ways to print the names without knowing the names. Another method might use CALL VNEXT.

[pre]
396 data _null_;
397 file log dsd;
398 if _n_ eq 1 then do;
399 if 0 then set sashelp.shoes;
400 put (_all_) (=) @;
401 _file_ = compress(tranwrd(_file_,'=',','),' .');
402 _file_ = substr(_file_,1,length(_file_)-1);
403 put;
404 end;
405 set sashelp.shoes(obs=30);
406 put (_all_)(:);
407 run;

Region,Product,Subsidiary,Stores,Sales,Inventory,Returns
Africa,Boot,Addis Ababa,12,"$29,761","$191,821",$769
Africa,Men's Casual,Addis Ababa,4,"$67,242","$118,036","$2,284"
Africa,Men's Dress,Addis Ababa,7,"$76,793","$136,273","$2,433"
Africa,Sandal,Addis Ababa,10,"$62,819","$204,284","$1,861"
Africa,Slipper,Addis Ababa,14,"$68,641","$279,795","$1,771"
Africa,Sport Shoe,Addis Ababa,4,"$1,690","$16,634",$79
Africa,Women's Casual,Addis Ababa,2,"$51,541","$98,641",$940
Africa,Women's Dress,Addis Ababa,12,"$108,942","$311,017","$3,233"
Africa,Boot,Algiers,21,"$21,297","$73,737",$710
Africa,Men's Casual,Algiers,4,"$63,206","$100,982","$2,221"
[/pre]

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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
  • 5 replies
  • 771 views
  • 0 likes
  • 4 in conversation