DATA Step, Macro, Functions and more

Need to create blank coulmns with out having any spaces and periods

Reply
Contributor
Posts: 64

Need to create blank coulmns with out having any spaces and periods

Dear experts,

 

I have a requirement from my client that need to populate a blank column but that should not be having any spaces or periods (full blank)

I know SAS can show this as either space or periods, but wanted to know is there any other soultion for this .

 

Thanks

 

Manesh

Super User
Super User
Posts: 7,994

Re: Need to create blank coulmns with out having any spaces and periods

Posted in reply to ambadi007

Erm, your question is very unclear.  This:

data want;
  a="";
run;

Creates a dataset with one emtpy variable named a (length 1).  Dots (.) are a feature of missing numerics, you can change this with options missing="";

Wouldn't recommend that though as it affects everything in the session.  Just create an emtpy string variable as above, length is irrelevant.  Cant see why spaces would matter.

Contributor
Posts: 64

Re: Need to create blank coulmns with out having any spaces and periods

Hi,

I created the variable like this a=' '; But this creating a space in the report, this gives errors while exporting the report from client system , so they need a complete blank instead of the space or periods.Thanks

Super User
Super User
Posts: 7,994

Re: Need to create blank coulmns with out having any spaces and periods

Posted in reply to ambadi007

Sorry, you will need to be far more specific - give examples (plain text in the post).  What report, what file format?  how are you creating it? If you look at the example I provided there was no space between the quote marks, in your post there is.  Remove that space.

Contributor
Posts: 64

Re: Need to create blank coulmns with out having any spaces and periods

Hi ,

 

I am using excel file to report it and I am exporting the file using DDE program. but for the blanks columns it should not show the space , now if I use the a="" it shows the space in the column cells , and If I use the backspace key it is removing the space. My requirement is is there any solution to remove the space. Hope now its  clear

Super User
Super User
Posts: 7,076

Re: Need to create blank coulmns with out having any spaces and periods

[ Edited ]
Posted in reply to ambadi007

Create a simple example that demonstrates the method you are using to export the data. DDE is not a normal method to use, Microsoft probably doesn't even want to support it anymore.

 

It is not hard to make a report with empty columns. For example a CSV file.

data _null_;
   file log dsd ;
   length var1-var3 $10;
   var1='A';
   var2=' ';
   var3='C';
   put var1-var3 ;
run;  

Reading the examples of DDE in this document http://support.sas.com/documentation/cdl/en/hostwin/63285/HTML/default/viewer.htm#ddeexamples.htm

it looks like it should be simple.

filename mydata dde 'excel|sheet1!r10c1:r20c3' notab;
data _null_; 
   file mydata dsd dlm='09'x  ;
   set mysas;
   put (_all_) (+0);
run;

 

Super User
Posts: 10,045

Re: Need to create blank coulmns with out having any spaces and periods

Posted in reply to ambadi007
proc format;
value fmt .='NA';
value $fmt ' '='NA';
run;
data x;
 x='sds';y=23;output;
 x=' ';y=34;output;
 x='dsd';y=.;output;
 format _numeric_ fmt. _character_ $fmt.;
run;
proc print;run;
run;
Super User
Posts: 5,516

Re: Need to create blank coulmns with out having any spaces and periods

Posted in reply to ambadi007

Technically, the answer is no.  You cannot create a character variable with length zero.

 

Conceivably, you could assign a null value to a character variable with code along these lines:

 

newvar='00'x;

 

But that is much more likely to cause downstream problems.

Contributor
Posts: 64

Re: Need to create blank coulmns with out having any spaces and periods

Posted in reply to Astounding

Hi This is affecting all other data

Super User
Posts: 11,343

Re: Need to create blank coulmns with out having any spaces and periods

Posted in reply to ambadi007

If you do not want anything in column C, for example, then do not write anything to column C. Write to B, Write to D but do not write to C. Then C will be "blank" as in whatever default Excel wants it.

 

 

Simple.

Ask a Question
Discussion stats
  • 9 replies
  • 182 views
  • 0 likes
  • 6 in conversation