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.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 7 replies
  • 2155 views
  • 6 likes
  • 5 in conversation