BookmarkSubscribeRSS Feed
josh_rodriguez
Calcite | Level 5

Hi All, and thanks in advance!!!

 

I recently found out that my File Writer transformation is outputting blank spaces instead of nulls. I need it to be nulls.

josh_rodriguez_0-1644446557575.png

I've tried several things, but to no avail. The closest thing that's gotten me to where I'm trying to go is to use the "Treat consecutive delimiters as a single delimiter" option on the very first File Reader transformation and then modifying the File Writer transformation code on the "put" section to display the field values without the ""s. And it does the trick. 
However, a big drawback is that it is cutting of the values of 1 or 2 other fields, for some reason. This is odd, because I double and triple-checked the lengths, formats, and informats of said fields on every single transformation and everything is in sync throughout all of the transformations.
josh_rodriguez_1-1644446583217.pngjosh_rodriguez_2-1644446600301.pngjosh_rodriguez_3-1644446610692.pngjosh_rodriguez_4-1644446618089.png

 

Again, thank you for any help you might give this SAS newbie!!!

-Josh

5 REPLIES 5
AllanBowe
Barite | Level 11

Hi Josh - if you're happy with a custom code transform you could try this macro: https://core.sasjs.io/mp__ds2csv_8sas.html

 

I just tested with this code:

data withnulls;
   length a b c $1;
   length d e f 8;
   call missing(of _all_);
run;

%mp_ds2csv(withnulls,outref="%sysfunc(pathname(work))/file.csv")

data _null_;
  infile "%sysfunc(pathname(work))/file.csv";
  input;
  putlog _infile_;
run;

And it generated this:

 

 A, B, C, D, E, F
 "" ,"" ,"" ,,,

If the blank space after the null value is a problem, we could get that removed.

 

 

/Allan
SAS Challenges - SASensei
MacroCore library for app developers
SAS networking events (BeLux, Germany, UK&I)

Data Workflows, Data Contracts, Data Lineage, Drag & drop excel EUCs to SAS 9 & Viya - Data Controller
DevOps and AppDev on SAS 9 / Viya / Base SAS - SASjs
josh_rodriguez
Calcite | Level 5

Thank you for your reply, Allan.
I was able to solve it. The concatenation function works- that's what I had to use in my Put statement, right before said Put statement.

josh_rodriguez_0-1645215250948.pngjosh_rodriguez_1-1645215258365.png

 

Tom
Super User Tom
Super User

In your first photograph of the text file you are generating there are a LOT of unneeded quotes. (Why did you post a photograph of text instead of just pasting the text into a text box?)  For example the values DCCC_CRJ and 88.78 have quotes around them.  Neither of those values contain either commas or quotes, so there was no need to add quotes around them in the CSV file.

 

Did you ask DI to insert all of those unneeded quotes? If so why?  How?

 

Can you show what actual SAS code DI generated to create the CSV file?

 

josh_rodriguez
Calcite | Level 5

Thank you for your reply, Tom.
I was able to solve it. The concatenation function works- that's what I had to use in my Put statement, right before said Put statement.

josh_rodriguez_0-1645215307123.png

 

josh_rodriguez_1-1645215312952.png

 

Tom
Super User Tom
Super User

So you got it to work?

 

Note: You posted photographs of text again. 

 

And you didn't answer why you need to jump through hoops to create such a non-standard file.  What is going to read the file that requires all of those unneeded quote characters?

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 connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 5 replies
  • 1286 views
  • 1 like
  • 3 in conversation