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

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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