BookmarkSubscribeRSS Feed
Sanflo
Fluorite | Level 6

Hi,

 

I was wondering if it is possible to be able and have SAS include a datasets headers in the first row of the data and also insert a row above that with a string value in the first column.

 

Below I've included some code which shows my sample data and what I am looking to achieve.

 

Any other questions or further information let me know.

 

Sandy

 

%let have_id = 'abc123';

proc sql noprint;
    create table work.have_data (test1 char(6),test2 char(6),test3 char(6))
    ;
    insert into work.have_data (test1,test2,test3)
        values ('a','b','c')
		values ('d','e','f')
		values ('g','h','i')
		values ('j','k','l')
    ;
quit;

proc sql noprint;
    create table work.want (col1 char(6),col2 char(6),col3 char(6))
    ;
    insert into work.want (col1,col2,col3)
		values (&have_id,'','')
		values ('test1','test2','test3')
        values ('a','b','c')
		values ('d','e','f')
		values ('g','h','i')
		values ('j','k','l')
    ;
quit;

4 REPLIES 4
Reeza
Super User
Why not use variable labels and/or data set labels if needed?
Tom
Super User Tom
Super User

What possible value could you get out of that?

Sounds like you want a print out of your data. Use PROC PRINT.

Here is an example:

%let dsn=sashelp.class(obs=3);
title "&dsn";
proc print data=&dsn;
run;

image.png

Kurt_Bremser
Super User

No, for several reasons:

  • you can't have strings in numeric columns
  • even if you only had character columns, variable names can easily exceed the defined length of the variable

Liberate yourself from Excel thinking.

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
  • 1992 views
  • 0 likes
  • 4 in conversation