×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Creating new variables without any data

Creating new variables without any data

Creating new variables without any data

(OP)
How can i create new variables but no data, like absolutely blank, no zero, no periods in SAS?

RE: Creating new variables without any data

In the normal data step, the trick is to stop SAS from returning to the top of the implicit loop. Metadata attributes get defined at compilation time, so you can define variables with formats, labels and lengths without having any records.

data step:

CODE

data blank1 ;
   dummy1 ='';
   dummy2 = 999 ;
   label dummy1 = 'Dummy variable 1'
         dummy2 = 'Dummy variable 2';
   stop ;
   run;
proc print;run;

SQL:

CODE

proc sql ;
  create table blank2
  (
     DUMMY1 CHAR(1) LABEL='Dummy variable 1',
     DUMMY2 NUM (8) LABEL='Dummy variable 2'
   ) ;
   quit ;

RE: Creating new variables without any data

(OP)
Well, I have already a dataset in which i wants to create multiple variables which are blank.

RE: Creating new variables without any data

Do you want to create blank character variables or numeric variables?

From your first post, I assume you mean numeric variables. SAS uses the period to highlight the missing variable is of type numeric, so other than using a format, I don't think you can change the appearance to a blank in the dataset. However for all reporting/printing purposes, you can use the missing option and set it to blank.

CODE

options missing=' ';
data class ;
   set sashelp.class ;
   call missing(x,y,z) ;*Create missing numerics x,y,z;
   run;
proc report data=class ;
   columns _all_ ;
   define _all_ / width=10 ;
   run;

For characters, a retain is probably the most efficient way:

CODE

data class ;
   set sashelp.class ;
   retain x y z '';
   run;
proc report data=class ;
   columns _all_ ;
   define _all_ / width=10 ;
   run;
  

RE: Creating new variables without any data

(OP)
We can use proc SQL, like Alter table statement, because i got the answer but let me try the code of yours.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close