11-24-2014 12:38 PM
instead of writing a code how do we add trailing blanks to alphanumeric fields using computed coloumn in SAS EG before exporting data into CSV file
11-24-2014 01:17 PM
All SAS character strings already are padded on the right with blanks.
So most likely your question is about how to generate a non standard CSV file that includes normally unwanted trailing blanks.
Why would you want to make a file in such a format?
Do you have more information on the required format since it is clearly not a normal CSV file.
11-24-2014 02:32 PM
i have an alphanumeric field example : MM344
its format is $12. In properties now I need to add trailing blanks
and length shd be 25 . and then export that dataset
as csv file
11-24-2014 02:43 PM
So the FORMAT is just how the variable is displayed, but let's assume that your variable also has a length of 12. You might get somewhere by just modifying the variable to use $25. format instead. If you really need to change the length of the variable then you will need to create a new variable.
But a CSV file will NOT have the trailing spaces. For example if you run this simple step you will see that the data for the character variable NAME does not have trailing spaces. The spaces are not needed because the commas serve as the delimiter between the fields. Hence the name Comma Separated Value (CSV).
682 data _null_;
683 set sashelp.class ;
684 file log dsd ;
685 put (_all_) (;
11-24-2014 02:51 PM
Perhaps your requirement is to output a fixed column format file instead of a CSV file? That is easy to so using a data step. Not sure if EG has a task to do that however.
file 'mynewfile.txt' ;
put @1 name @26 age @30 sex ;
11-24-2014 04:57 PM
CCan we use subpad function but I am confused of which length I can specify and which format I can specify in code when source has format $12. , length 12 and now result dataset format A25 . Thinking how to represent in code
11-24-2014 05:25 PM
If you are writing your own code then just define the variable to the length you want.
If you are writing a data step then use the LENGTH statement to define the variable.
data want ;
set have ;
length new $25;
If you are writing SQL then use the LENGTH attribute
proc sql ;
create table want as select *,old as new length=25 from have ;