Help using Base SAS procedures

Double quotes around numeric variables??

Reply
Frequent Contributor
Posts: 75

Double quotes around numeric variables??

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?
Respected Advisor
Posts: 3,799

Re: Double quotes around numeric variables??

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"

Frequent Contributor
Posts: 75

Re: Double quotes around numeric variables??

Posted in reply to data_null__
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",,,,,,
Respected Advisor
Posts: 3,799

Re: Double quotes around numeric variables??

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]
Frequent Contributor
Posts: 75

Re: Double quotes around numeric variables??

Posted in reply to data_null__
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
SAS Super FREQ
Posts: 8,864

Re: Double quotes around numeric variables??

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
Ask a Question
Discussion stats
  • 5 replies
  • 1706 views
  • 0 likes
  • 3 in conversation