BookmarkSubscribeRSS Feed
G_I_Jeff
Obsidian | Level 7
Need to add double quotes around certain formatted numeric variables for a comma delimited file. Is there an easy way to accomplish without converting numeric variables to character?
5 REPLIES 5
data_null__
Jade | Level 19

Are you thinking of something like this?

6617  data _null_;

6618    file log dsd;

6619    set sashelp.class;

6620    put (_all_)(~);

6621    run;

"Alfred","M","14","69","112.5"

"Alice","F","13","56.5","84"

"Barbara","F","13","65.3","98"

"Carol","F","14","62.8","102.5"

"Henry","M","14","63.5","102.5"

"James","M","12","57.3","83"

"Jane","F","12","59.8","84.5"

G_I_Jeff
Obsidian | Level 7
Sorry, no.
I need to double quote specific numeric fields before I plug them into a csv file. It won't be all the fields.

Example:
SMF30ZIP,20110620,3,Acct_Code,"997KCE999999",Acct_Code2,"KCUN",Acct_Code3,"3",Shift,"1",JESNR,"JOB07760",,,,,,
data_null__
Jade | Level 19
Perhaps,

[pre]
6627 data _null_;
6628 file log dsd;
6629 set sashelp.class;
6630 put name age ~ sex height weight ~;
6631 run;

Alfred,"14",M,69,"112.5"
Alice,"13",F,56.5,"84"
Barbara,"13",F,65.3,"98"
Carol,"14",F,62.8,"102.5"
Henry,"14",M,63.5,"102.5"
James,"12",M,57.3,"83"
Jane,"12",F,59.8,"84.5"
Janet,"15",F,62.5,"112.5"
Jeffrey,"13",M,62.5,"84"

[/pre]
G_I_Jeff
Obsidian | Level 7
Once again, you prove yourself a pro....
Works perfectly. I ran across another posting where you had the (_all_) statement in it, but I didn't realize what exactly the ~ character was accomplishing. Now I know!

Regards,
G.I. Jeff
Cynthia_sas
Diamond | Level 26
Relevant Tech Support notes on using the tilde format modifier:
http://support.sas.com/kb/8/082.html
http://support.sas.com/kb/4/765.html

cynthia
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 5361 views
  • 0 likes
  • 3 in conversation