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
SAS Super FREQ
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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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