user2704338
user2704338

Reputation: 89

SAS: Read File scattered across lines

I have data in the .txt file as:

VALUE   ADM_LN2G                                                            
               1     = 'ENGLISH'                                            
               2     = 'FRENCH'                                             
               3     = 'ARABIC'                                             
               4     = 'CHINESE'                                            
               5     = 'CREE'                                               
               6     = 'GERMAN'                                             
               7     = 'GREEK'                                              
                   ;                                                        
VALUE   ADM_LNG                                                             
              24     = 'INUKTITUT'                                          
              90     = 'OTHER'                                              
              96     = 'NOT APPLICABLE'                                     
              97     = 'DON''T KNOW'                                        
              98     = 'REFUSAL'                                            
              99     = 'NOT STATED'                                         
                   ; 

. . . . I want to separate out each value in different dataset. Output expected: Dataset 1 : ADM_LN2G
VALUE ADM_LN2G
1 = 'ENGLISH'
2 = 'FRENCH'
3 = 'ARABIC'
4 = 'CHINESE'
5 = 'CREE'
6 = 'GERMAN'
7 = 'GREEK'
; Dataset 2: ADM_LNG

VALUE   ADM_LNG                                                             
              24     = 'INUKTITUT'                                          
              90     = 'OTHER'                                              
              96     = 'NOT APPLICABLE'                                     
              97     = 'DON''T KNOW'                                        
              98     = 'REFUSAL'                                            
              99     = 'NOT STATED' 
                   ; 

etc.

For every VALUE there is ";" at the end. Please help! Thanks in advance!!

Upvotes: 0

Views: 33

Answers (1)

Tom
Tom

Reputation: 51566

If the file is valid code for creating SAS formats then you can get at the data by letting SAS create the formats.

proc format lib=work.newformats;
%include "source file";
run;

Then use PROC FORMAT to export the formats to a data set.

proc format lib=work.newformats cntlout=WANT(keep=fmtname start label);
run;

Upvotes: 2

Related Questions