BookmarkSubscribeRSS Feed
sasuser123123
Quartz | Level 8
Hi
I have data..
Data new;
input id ba
Cards;
101
101
101
101
101 5
102
102
102
102 9

So I need to retain all obs with last value of I'd can anyone help me how to do
4 REPLIES 4
ChrisNZ
Tourmaline | Level 20

Please paste you code using the appropriate icon.

 

And show us your expected output.

Kurt_Bremser
Super User
 72         
 73         Data new;
 74         input id ba
 75         Cards;
 76         101
            ___
            180
 ERROR 180-322: Statement is not valid or it is used out of proper order.
 
 77         101
 78         101
 79         101
 80         101 5
 81         102
 82         102
 83         102
 84         102 9
 85         
 86         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 87         ODS HTML CLOSE;
 88         &GRAPHTERM; ;*';*";*/;RUN;
 
 ERROR: No DATALINES or INFILE statement.
 NOTE: The SAS System stopped processing this step because of errors.
 WARNING: The data set WORK.NEW may be incomplete.  When this step was stopped there were 0 observations and 3 variables.
 NOTE:  Verwendet wurde: DATA statement - (Gesamtverarbeitungszeit):
       real time           0.00 seconds
       cpu time            0.00 seconds
Astounding
PROC Star

Taking a guess at what you hope to achieve ...

 

This program would move in the right direction, by selecting observations with a nonmissing value for BA:

 

data want;
   set new;
   where ba > .;
run;

And this program would take it a step further, selecting just the last such observation for each ID:

data want;
   set new;
   where ba > .;
   by id;
   if last.id;
run;
Sajid01
Meteorite | Level 14

If you want to read all observations, update your code as follows

Data new;
input id ba;
infile datalines missover;
datalines;
101 
101 
101 
101 
101 5
102 
102 
102 
102 9
;
run;
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
  • 4 replies
  • 1141 views
  • 0 likes
  • 5 in conversation