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

I have data in the format where there are variable from eci01nam to eci20nam. Only one value would be present for each observation. 

i want to get that non missing  value into new variable.

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Use a CAT function to pull the information in.


WANT = CATS(of eci01nam-eci20nam);

@yashraj89 wrote:

I have data in the format where there are variable from eci01nam to eci20nam. Only one value would be present for each observation. 

i want to get that non missing  value into new variable.


 

View solution in original post

7 REPLIES 7
Reeza
Super User

Use a CAT function to pull the information in.


WANT = CATS(of eci01nam-eci20nam);

@yashraj89 wrote:

I have data in the format where there are variable from eci01nam to eci20nam. Only one value would be present for each observation. 

i want to get that non missing  value into new variable.


 

yashraj89
Obsidian | Level 7

I think it will work but first i have to convert the variable numeric suffix. It throughs the error

ERROR: Missing numeric suffix on a numbered variable list (eci01nam-eci18nam).
ERROR 71-185: The CATS function call does not have enough arguments.

Astounding
PROC Star
It's easy as long as those 20 are the only variable names that begin with "eci":

newvar = max (of eci: ) ;
Reeza
Super User
I think MAX() only works on numeric variables in a data step.
novinosrin
Tourmaline | Level 20

@Reeza  Mam , Are you telling me you forgot coalescec?

WANT = coalescec(of eci01nam-eci20nam);

 

Or did you not have coffee or you must be tired?

Astounding
PROC Star

You're right.  I was using a handheld where I couldn't actually see the sample data.  Oh well.

ballardw
Super User

Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 7 replies
  • 2250 views
  • 5 likes
  • 5 in conversation