SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
sandhya88
Calcite | Level 5

DATA HAVEDATA HAVEDATA WANTDATA WANT

 

In the above images the data that i have is on the left side in a table where only few records are having CRITFl populated for the ID.

The image on the right is what i want to achieve populating the value of critfl across all the records of the ID.

 

Any Suggestions are grateful.

 

TIA

2 REPLIES 2
PaigeMiller
Diamond | Level 26

What happens if the ID has both Y and N? What happens if the ID has neither Y nor N?

 

Please do not type in ALL CAPITALS.

 

Please provide example data as SAS data step code, which you can type in yourself or you can get by following these instructions (and not via screen captures or via file attachments). We cannot write code to read screen captures.

--
Paige Miller
sandhya88
Calcite | Level 5
 
Data have;
input ID$ PARAMCD$ RESULT BASERSLT CRITFL$;
datelines;
004	ALT	       0.03	 0.03	
004	ALT	       0.06	 0.03	
004	AST	       0.03	 0.03	
004	CHOL      0.03	 0.03	
004	4HCHOL	  0.03	 0.03	
004	ALT	      0.12	 0.03        Y
004	LIPA	  0.09	 0.09	
005	ALT   	  0.03	 0.03	
005	AST	      0.06	 0.04	
005	CHOL	  0.03	 0.03	
005	4HCHOL	  0.03	 0.03	
005	ALT	      0.06   0.03	     N
005	LIPA	  0.12	 0.12	
;
Data want;
input ID$ PARAMCD$ RESULT BASERSLT CRITFL$;
datelines;
004	ALT	      0.03	 0.03	Y
004	ALT	      0.06	 0.03	Y
004	AST	      0.03	 0.03	Y
004	CHOL      0.03	 0.03	Y
004	4HCHOL	  0.03 0.03	Y
004	ALT	        0.12	  0.03   Y
004	LIPA	  0.09	 0.09	Y
005	ALT   	  0.03	 0.03	N
005	AST	      0.06	 0.04	N
005	CHOL	  0.03	 0.03   N	
005	4HCHOL	  0.03	 0.03   N	
005	ALT	      0.06   0.03	N
005	LIPA	  0.12	 0.12	N;


1.CRITFL for the ID will have either "Y" or "N" and not a combination and hence if at least one record of ID has a "Y" or "N" or even "" i want to see that being retained to all the other records of the ID.


Hope this is a bit helpful and apologies for the attachments.

Thanks

sas-innovate-white.png

Join us for our biggest event of the year!

Four days of inspiring keynotes, product reveals, hands-on learning opportunities, deep-dive demos, and peer-led breakouts. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 653 views
  • 1 like
  • 2 in conversation