BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mhoward2
Obsidian | Level 7

I cannot run this code for the life of me. I am trying to use some variables to pull data and am coming up short no matter what I try. here is the bit of code

 

    PROC SQL;
     CREATE TABLE WORK.MEMBERSHIP_TABLE AS
      SELECT   t1.UNIQ_ID,
          t1.Year_Month_Text AS INCURRED_YYYYMM,
          t2.Group
      FROM WORK.THISTABLE&Paid_YYYYMM t1
       INNER JOIN WORK.THATTABLE_MBRS t2 ON t1.UNIQ_ID = t2.UNIQ_ID
      WHERE t1.Year_Month_Text BETWEEN &Start_YYYYMM AND &End_YYYYMM;
    QUIT;

 

Here is the log that keep outputting, you can see my variables are correct and I promise that the columns they are associated with are character columns.

 

    35         PROC SQL;
    36          CREATE TABLE WORK.MEMBERSHIP_MDCR AS
    37           SELECT   t1.UNIQ_ID,
    38               t1.Year_Month_Text AS INCURRED_YYYYMM,
    39               t2.Group
    42           FROM WORK.THISTABLE&Paid_YYYYMM t1
    SYMBOLGEN:  Macro variable PAID_YYYYMM resolves to 201908
    43            INNER JOIN WORK.THATTABLE_MBRS t2 ON t1.UNIQ_ID = t2.UNIQ_ID
    2                                                          The SAS System                         09:03 Thursday, September 12, 2019
    44           WHERE t1.Year_Month_Text BETWEEN &Start_YYYYMM AND &End_YYYYMM;
    SYMBOLGEN:  Macro variable START_YYYYMM resolves to 201901
    SYMBOLGEN:  Macro variable END_YYYYMM resolves to 201907
    ERROR: Expression using IN has components that are of different data types.
 
Aren't variables automatically character variables and not numeric? What do I do to make sure they are character?
 
Thanks
1 ACCEPTED SOLUTION

Accepted Solutions
mhoward2
Obsidian | Level 7

Thanks for the response Paige!! Someone answered my question though, I needed double qoutees "" on either side of the start and end variables. Fixed it right up!

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26

Please run PROC CONTENTS on the data set WORK.THISTABLE&Paid_YYYYMM and see whether variable Year_Month_Text is character or numeric. (Don't say "I know it's numeric" or "I know its character" ... I want to know what PROC CONTENTS says)

 

If it is a character variable, then this could be the problem, because a character variable cannot be between the numeric integers 201901 and 201907.

 

When trying to create code that works with macro variables, you absolutely must first create working code without macros and without macro variables for one situation. If you can't get that to work, you will never get code to work with macro variables. Once you have working code without macros and without macro variables, then you have a good chance of getting the code to work with macro variables.

--
Paige Miller
mhoward2
Obsidian | Level 7

Thanks for the response Paige!! Someone answered my question though, I needed double qoutees "" on either side of the start and end variables. Fixed it right up!

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 2 replies
  • 3950 views
  • 0 likes
  • 2 in conversation