Help using Base SAS procedures

create .csv without blanks

Reply
Occasional Contributor
Posts: 13

create .csv without blanks

Hi I´m trying to create a .csv without blancs in the character variables not informated, but I only arrived to obtain

xxx; ;xxxx

insted of

xxx;;xxxx  (without blanks).


I´m ussing data _null_ becouse I need to write the first line with some variables and the others with other diferent variables.

Mycode is


options missing='';

  data _null_;

  file "/DIOGEN/REPORTINGOS/IPCA_INFOINSTAL_D_&nombre&gui&fec&csv"   dlm=';';

  

  set TmpHC.&SISTEMA;

  if _n_ = 1 then        /* write column names or labels */

               do;

                put @01  IdentificacionMensaje

     VersionMensaje

     TipoMensaje

  TipoProceso

  TipoSubproceso

  IdSistema

  CodificacionSistema

  IdentificacionRemitente

  CodificacionRemitente

  FuncionRemitente

  IdentificacionDestinatario

  codificacionDestinatario

  FuncionDestinatario

  FechaHoraMensaje

  Horizonte    

                ;

  end;

  if _n_ >= 1 then        /* write column names or labels */

               do;

                put @01  IdentificadorSerieTemporal

  UPR

  CodificacionUPR

  Central

  CodificacionCentral

  UnidadMedida

  IntervaloTiempo

  Resolucion

  Pos

  Produccion

  ConsumoPropio

  Consumo

  EnergiaDisponible 

                        ;

   end;

  run;

/

How can I do for obtain it?

Thanks


Regular Contributor
Posts: 180

Re: create .csv without blanks

IMO the blank will not hurt at all when you read the .cvs file.

Take into account that SAS represents missing values with a . for numeric variables and with a blank for character variables.

CTorres

Super User
Super User
Posts: 6,498

Re: create .csv without blanks

Why not just use the DSD option on the FILE statement?  That is what it is for.

Occasional Contributor
Posts: 13

Re: create .csv without blanks

It´s a client requirement.

I said than a blank it´s not a problem but has said NO.

So, I cant put ' '

I know that with proc export there is not this problem, but i´ve the problem that i think it´s not possible to writte differtent formats for diferent rows.

So, I cant put blaknk

Occasional Contributor
Posts: 13

Re: create .csv without blanks

Sorry Tom, I dont know how to use the dsd option for that, can you explain me please?

On other hand I think they are going to use the csv to charge values into html, but the obtion of blank is not acepted.

Super User
Super User
Posts: 6,498

Re: create .csv without blanks

1) read the man page. 

    Actually the online man page for the DSD option on the INFILE statement explains better than the section in the FILE statement.

 When you specify DSD, SAS treats two consecutive delimiters as a missing value and removes quotation marks from character values.

2) try a little experiment.

data _null_;

   set sashelp.class ;

   if _n_=1 then age=.;

  if _n_=2 then name = ' ';

  file log dsd ;

  put (_all_) (Smiley Happy;

run;

Occasional Contributor
Posts: 13

Re: create .csv without blanks

Tom, I´m looking for the utility of DSD and I´ve make a proof.

It seem to be perfect, but I would like to know exactly what is it for.

Thanks a lot!!

Ask a Question
Discussion stats
  • 6 replies
  • 267 views
  • 0 likes
  • 3 in conversation