BookmarkSubscribeRSS Feed
PFAN
Calcite | Level 5

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


6 REPLIES 6
CTorres
Quartz | Level 8

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

Tom
Super User Tom
Super User

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

PFAN
Calcite | Level 5

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

PFAN
Calcite | Level 5

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.

Tom
Super User Tom
Super User

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_) (:);

run;

PFAN
Calcite | Level 5

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!!

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 6 replies
  • 983 views
  • 0 likes
  • 3 in conversation