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.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 7 replies
  • 1259 views
  • 5 likes
  • 5 in conversation