BookmarkSubscribeRSS Feed
Zachary
Obsidian | Level 7

proc sql noprint;

  create table TextForAnalysis as

  select distinct TextCommentsColumn into :TextFromExcel separated by ' '

    from TextSingleColumn;

quit;

%put &=TextFromExcel &=sqlobs;

I get two warnings. 1. Apparent Symbolic Reference TextFromExcel not resolved & 2. into clause ignored in the create table statement.

But, everything looks ok in terms of the creation of the TextForAnalysis table.

I would like to tighten it up a bit - any and all help is appreciated.

7 REPLIES 7
Ksharp
Super User

Remove  Create table .

stat_sas
Ammonite | Level 13

You are trying to create a macro variable not a table. As, Xia mentioned remove the create table. Also this requires a small modification

%put &TextFromExcel &sqlobs;

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Just to add to the above, why would you want to put textfromexcel into a macro variable.  This could create a vast string, and macro processing of lists is to my mind not suited to lists.  Why not just keep the distinct values in a table?

Zachary
Obsidian | Level 7

Thank you very much. Now I am confused - had no intention at all of creating a macro variable. My intention was to take a table of about 4,000 words that have duplicates and remove the duplicates with the proc sql code. What I would be left with is an alphabetized list of unique words - should come to around 1,000+.

Reeza
Super User

What does your dataset TEXTSINGLECOLUMN look like, is it a dataset of one word per row with duplicates?

If you need to separate the words into rows thats a different issue - not quite suited to SQL in my opinion.

If so:

proc sql noprint;

  create table TextForAnalysis as

  select distinct TextCommentsColumn

    from TextSingleColumn

    order by textcommentscolumn;

quit;

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Then you don't need this bit of code: into :TextFromExcel separated by ' '

Zachary
Obsidian | Level 7

Thank you very much for all of the helpful answers & suggestions.

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
  • 7 replies
  • 1127 views
  • 6 likes
  • 5 in conversation