DATA Step, Macro, Functions and more

how to represent variables starting with same word in a single variable in SAS 9.3

Reply
Occasional Contributor
Posts: 7

how to represent variables starting with same word in a single variable in SAS 9.3


Hi All,

In our project we have a variable starting with Wk_1 to Wk_100.

We have to represent it in a single variable in a data step. we have to read all the variables that starts with Wk

Our code goes like this

data test1;

set test2;

keep col1 col2 Wk_:;

run;

This works fine in SAS 9.1.3 but it throws error in SAS 9.3

Could anyone suggest an alternative for this.

Contributor
Posts: 62

Re: how to represent variables starting with same word in a single variable in SAS 9.3

Hi,

Example 3 in this paper may help you to find your answer : Use the Full Power of SAS® in Your Function-Style Macros

Respected Advisor
Posts: 3,777

Re: how to represent variables starting with same word in a single variable in SAS 9.3

The syntax looks correct.  What is the error?

Occasional Contributor
Posts: 7

Re: how to represent variables starting with same word in a single variable in SAS 9.3

The variables are not getting resolved in SAS 9.3

It is getting resolved in SAS 9.1.3.

Super Contributor
Posts: 333

Re: how to represent variables starting with same word in a single variable in SAS 9.3

Thats interesting I would have thought it was the other way around ... I thought the colon abbreviation is relative new addition to the code base like in version 9.2.

I use the colon shortcut all the time in 9.3.

EJ

Respected Advisor
Posts: 3,777

Re: how to represent variables starting with same word in a single variable in SAS 9.3

But you didn't show the error message.  "not getting resolved" is not an error message.

SAS Super FREQ
Posts: 8,743

Re: how to represent variables starting with same word in a single variable in SAS 9.3

Hi:

  If you have something that works in one version of SAS, but not in another version of SAS, your best resource is to open a track with Tech Support. The doc for SAS 9.3 references name prefix lists as being valid SAS(R) 9.3 Language Reference: Concepts, Second Edition and so, Tech Support has both versions (9.1.3 and 9.3) in which to test your code.

  To open a track with Tech Support, you can go to support.sas.com and click on the link for "Submit a Problem" on the left hand navigation pane.

cynthia

Ask a Question
Discussion stats
  • 6 replies
  • 291 views
  • 0 likes
  • 5 in conversation