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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 2048 views
  • 0 likes
  • 4 in conversation