BookmarkSubscribeRSS Feed
shynu
Fluorite | Level 6

How do I select the first non missing value??

 

Write a program to get the below O/P:
i/P:
1
12
123
1234


o/p:
0001
0012
0123
1234

4 REPLIES 4
RW9
Diamond | Level 26 RW9
Diamond | Level 26

1) What do you mean by "select the first"?  Do you only want to output to dataset the first one?  

2)

data want;
length op $4; set have; op=put(ip,z4.); run;

The Zx. format will put out the zeroes.

Reeza
Super User

Your question statement has no relation to your desired output...

shynu
Fluorite | Level 6

I'am sorry, they are 2 different questions.

 And in the first question I mean to ask, if there are a set of observations with missing and non missing values of a variable, how can I output the 1st non missing value of that variable.

 

Thank you.

Reeza
Super User

@shynu wrote:

I'am sorry, they are 2 different questions.

 And in the first question I mean to ask, if there are a set of observations with missing and non missing values of a variable, how can I output the 1st non missing value of that variable.

 

Thank you.


 

 

Post sample input/output as well. 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 4 replies
  • 858 views
  • 0 likes
  • 3 in conversation