BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.

Hi,

 

I am not sure why not.

 

Below is the code:

 

Libname Review'/folders/myfolders/Review' ;
Libname Learn'/folders/myfolders/Learn' ;  
Libname myformat'/folders/myfolders/sasuser.v94' ;
Options fmtsearch = (myformat) ;

Data review.Prob21_10 ;
    Infile '/folders/myfolders/SASData/mixed_recs.txt' pad;
    Input @16 Code 2. @ ;
        If Code eq 1 then do ;
            out = SalesReview ;
            input @1 Date mmddyy10.  
                 @ 12 Amount 4. ;
             format date mmddyy10. ;
        End ;
        Else if Code ne 1 then do ;     
            out = InventoryReview ;
            input PartNumber  $8.  
                  Quantity 8. ;  
        End ;
run ;

Data Review.SalesReview_Only ;
    Set SalesReview ;
    Select ;
        When  (Not Missing(Date))  Put Date = ;
        When (Not Missing(Amount)) Put Amount = ;
        Otherwise ;
    End ;
run ;

Data Review.InventoryReview_Only ;
    Set InventoryReview ;
    Select ;
        When  (Not Missing(Partnumber))  Put Partnumber = ;
        When (Not Missing(Quantity)) Put Quantity = ;
        Otherwise ;
    End ;
run ;

proc print data=review.Salesreview_only noobs ;
run ;

proc print data=review.Inventoryreview_only noobs ;
run ;

Below is the raw data from the infile:

10/21/2005  1001
11/15/2005  2001
A13688 250     2
B11112 300     2
01/03/2005 50001
A88778 19      2

Finally, below is the log.

 

1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
61
62 Libname Review'/folders/myfolders/Review' ;
NOTE: Libref REVIEW was successfully assigned as follows:
Engine: V9
Physical Name: /folders/myfolders/Review
63 Libname Learn'/folders/myfolders/Learn' ;
NOTE: Libref LEARN refers to the same physical library as LEARN2.
NOTE: Libref LEARN was successfully assigned as follows:
Engine: V9
Physical Name: /folders/myfolders/Learn
64 Libname myformat'/folders/myfolders/sasuser.v94' ;
NOTE: Libref MYFORMAT refers to the same physical library as SASUSER.
NOTE: Libref MYFORMAT was successfully assigned as follows:
Engine: V9
Physical Name: /folders/myfolders/sasuser.v94
65 Options fmtsearch = (myformat) ;
66
67 Data review.Prob21_10 ;
68 Infile '/folders/myfolders/SASData/mixed_recs.txt' pad;
69 Input @16 Code 2. @ ;
70 If Code eq 1 then do ;
71 out = SalesReview ;
72 input @1 Date mmddyy10.
73 @ 12 Amount 4. ;
74 format date mmddyy10. ;
75 End ;
76 Else if Code ne 1 then do ;
77 out = InventoryReview ;
78 input PartNumber  $8.
79 Quantity  8. ;
80 End ;
81 run ;
 
NOTE: Variable SalesReview is uninitialized.
NOTE: Variable InventoryReview is uninitialized.
NOTE: The infile '/folders/myfolders/SASData/mixed_recs.txt' is:
Filename=/folders/myfolders/SASData/mixed_recs.txt,
Owner Name=sasdemo,Group Name=sas,
Access Permission=-rw-rw-r--,
Last Modified=23Aug2017:10:33:41,
File Size (bytes)=106
 
NOTE: LOST CARD.
Code=2 out=. SalesReview=. Date=. Amount=. InventoryReview=. PartNumber= Quantity=. _ERROR_=1 _N_=5
NOTE: 6 records were read from the infile '/folders/myfolders/SASData/mixed_recs.txt'.
The minimum record length was 16.
The maximum record length was 16.
NOTE: SAS went to a new line when INPUT statement reached past the end of a line.
NOTE: The data set REVIEW.PROB21_10 has 4 observations and 8 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds
 
 
82
83 Data Review.SalesReview_Only ;
84 Set SalesReview ;
ERROR: File WORK.SALESREVIEW.DATA does not exist.
85 Select ;
86 When (Not Missing(Date)) Put Date = ;
87 When (Not Missing(Amount)) Put Amount = ;
88 Otherwise ;
89 End ;
90 run ;
 
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set REVIEW.SALESREVIEW_ONLY may be incomplete. When this step was stopped there were 0 observations and 2
variables.
WARNING: Data set REVIEW.SALESREVIEW_ONLY was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds
 
 
91
92 Data Review.InventoryReview_Only ;
93 Set InventoryReview ;
ERROR: File WORK.INVENTORYREVIEW.DATA does not exist.
94 Select ;
95 When (Not Missing(Partnumber)) Put Partnumber = ;
96 When (Not Missing(Quantity)) Put Quantity = ;
97 Otherwise ;
98 End ;
99 run ;
 
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set REVIEW.INVENTORYREVIEW_ONLY may be incomplete. When this step was stopped there were 0 observations and 2
variables.
WARNING: Data set REVIEW.INVENTORYREVIEW_ONLY was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
 
 
100
101 proc print data=review.Salesreview_only noobs ;
102 run ;
 
NOTE: No observations in data set REVIEW.SALESREVIEW_ONLY.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
 
 
103
104 proc print data=review.Inventoryreview_only noobs ;
105 run ;
 
NOTE: No observations in data set REVIEW.INVENTORYREVIEW_ONLY.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds
 
 
106
107
108
109
110 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Where are you expecting a data set SalesReview to be created? I only see the initial data set being created, review. prob21_10. 

 

And looking at that step it's full of errors so your issues is likely right there. Whatever you're assuming is happening in that step is not happening. 

 

See my questions here:

Data review.Prob21_10 ; 
    Infile '/folders/myfolders/SASData/mixed_recs.txt' pad;
    Input @16 Code 2. @ ;
        If Code eq 1 then do ;
            out = SalesReview ; *<- Do you think this creates a record in the SALESREVIEW dataset, it does not. It assigns a value to the variable OUT that is missing because a variable named SSALESREVIEW does not exist;
            input @1 Date mmddyy10.  
                 @ 12 Amount 4. ;
             format date mmddyy10. ;
        End ;
        Else if Code ne 1 then do ;     
            out = InventoryReview ;
            input PartNumber  $8.  
                  Quantity 8. ;  
        End ;
run ;

 

 

If you're trying to create multiple data sets you want OUTPUT (not OUT) and you need to explicitly list the names at the top of the data set. Additionally, you probably want it at the end of the IF/THEN/DO loop otherwise it will be empty values until you read them in.


@ManitobaMoose wrote:

Hi,

 

I am not sure why not.

 

Below is the code:

 

Libname Review'/folders/myfolders/Review' ;
Libname Learn'/folders/myfolders/Learn' ;  
Libname myformat'/folders/myfolders/sasuser.v94' ;
Options fmtsearch = (myformat) ;

Data review.Prob21_10 ;
    Infile '/folders/myfolders/SASData/mixed_recs.txt' pad;
    Input @16 Code 2. @ ;
        If Code eq 1 then do ;
            out = SalesReview ;
            input @1 Date mmddyy10.  
                 @ 12 Amount 4. ;
             format date mmddyy10. ;
        End ;
        Else if Code ne 1 then do ;     
            out = InventoryReview ;
            input PartNumber  $8.  
                  Quantity 8. ;  
        End ;
run ;

Data Review.SalesReview_Only ;
    Set SalesReview ;
    Select ;
        When  (Not Missing(Date))  Put Date = ;
        When (Not Missing(Amount)) Put Amount = ;
        Otherwise ;
    End ;
run ;

Data Review.InventoryReview_Only ;
    Set InventoryReview ;
    Select ;
        When  (Not Missing(Partnumber))  Put Partnumber = ;
        When (Not Missing(Quantity)) Put Quantity = ;
        Otherwise ;
    End ;
run ;

proc print data=review.Salesreview_only noobs ;
run ;

proc print data=review.Inventoryreview_only noobs ;
run ;

Below is the raw data from the infile:

10/21/2005  1001
11/15/2005  2001
A13688 250     2
B11112 300     2
01/03/2005 50001
A88778 19      2

Finally, below is the log.

 

1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
61
62 Libname Review'/folders/myfolders/Review' ;
NOTE: Libref REVIEW was successfully assigned as follows:
Engine: V9
Physical Name: /folders/myfolders/Review
63 Libname Learn'/folders/myfolders/Learn' ;
NOTE: Libref LEARN refers to the same physical library as LEARN2.
NOTE: Libref LEARN was successfully assigned as follows:
Engine: V9
Physical Name: /folders/myfolders/Learn
64 Libname myformat'/folders/myfolders/sasuser.v94' ;
NOTE: Libref MYFORMAT refers to the same physical library as SASUSER.
NOTE: Libref MYFORMAT was successfully assigned as follows:
Engine: V9
Physical Name: /folders/myfolders/sasuser.v94
65 Options fmtsearch = (myformat) ;
66
67 Data review.Prob21_10 ;
68 Infile '/folders/myfolders/SASData/mixed_recs.txt' pad;
69 Input @16 Code 2. @ ;
70 If Code eq 1 then do ;
71 out = SalesReview ;
72 input @1 Date mmddyy10.
73 @ 12 Amount 4. ;
74 format date mmddyy10. ;
75 End ;
76 Else if Code ne 1 then do ;
77 out = InventoryReview ;
78 input PartNumber  $8.
79 Quantity  8. ;
80 End ;
81 run ;
 
NOTE: Variable SalesReview is uninitialized.
NOTE: Variable InventoryReview is uninitialized.
NOTE: The infile '/folders/myfolders/SASData/mixed_recs.txt' is:
Filename=/folders/myfolders/SASData/mixed_recs.txt,
Owner Name=sasdemo,Group Name=sas,
Access Permission=-rw-rw-r--,
Last Modified=23Aug2017:10:33:41,
File Size (bytes)=106
 
NOTE: LOST CARD.
Code=2 out=. SalesReview=. Date=. Amount=. InventoryReview=. PartNumber= Quantity=. _ERROR_=1 _N_=5
NOTE: 6 records were read from the infile '/folders/myfolders/SASData/mixed_recs.txt'.
The minimum record length was 16.
The maximum record length was 16.
NOTE: SAS went to a new line when INPUT statement reached past the end of a line.
NOTE: The data set REVIEW.PROB21_10 has 4 observations and 8 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds
 
 
82
83 Data Review.SalesReview_Only ;
84 Set SalesReview ;
ERROR: File WORK.SALESREVIEW.DATA does not exist.
85 Select ;
86 When (Not Missing(Date)) Put Date = ;
87 When (Not Missing(Amount)) Put Amount = ;
88 Otherwise ;
89 End ;
90 run ;
 
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set REVIEW.SALESREVIEW_ONLY may be incomplete. When this step was stopped there were 0 observations and 2
variables.
WARNING: Data set REVIEW.SALESREVIEW_ONLY was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds
 
 
91
92 Data Review.InventoryReview_Only ;
93 Set InventoryReview ;
ERROR: File WORK.INVENTORYREVIEW.DATA does not exist.
94 Select ;
95 When (Not Missing(Partnumber)) Put Partnumber = ;
96 When (Not Missing(Quantity)) Put Quantity = ;
97 Otherwise ;
98 End ;
99 run ;
 
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set REVIEW.INVENTORYREVIEW_ONLY may be incomplete. When this step was stopped there were 0 observations and 2
variables.
WARNING: Data set REVIEW.INVENTORYREVIEW_ONLY was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
 
 
100
101 proc print data=review.Salesreview_only noobs ;
102 run ;
 
NOTE: No observations in data set REVIEW.SALESREVIEW_ONLY.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
 
 
103
104 proc print data=review.Inventoryreview_only noobs ;
105 run ;
 
NOTE: No observations in data set REVIEW.INVENTORYREVIEW_ONLY.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds
 
 
106
107
108
109
110 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;

 


 

View solution in original post

3 REPLIES 3
Reeza
Super User

Where are you expecting a data set SalesReview to be created? I only see the initial data set being created, review. prob21_10. 

 

And looking at that step it's full of errors so your issues is likely right there. Whatever you're assuming is happening in that step is not happening. 

 

See my questions here:

Data review.Prob21_10 ; 
    Infile '/folders/myfolders/SASData/mixed_recs.txt' pad;
    Input @16 Code 2. @ ;
        If Code eq 1 then do ;
            out = SalesReview ; *<- Do you think this creates a record in the SALESREVIEW dataset, it does not. It assigns a value to the variable OUT that is missing because a variable named SSALESREVIEW does not exist;
            input @1 Date mmddyy10.  
                 @ 12 Amount 4. ;
             format date mmddyy10. ;
        End ;
        Else if Code ne 1 then do ;     
            out = InventoryReview ;
            input PartNumber  $8.  
                  Quantity 8. ;  
        End ;
run ;

 

 

If you're trying to create multiple data sets you want OUTPUT (not OUT) and you need to explicitly list the names at the top of the data set. Additionally, you probably want it at the end of the IF/THEN/DO loop otherwise it will be empty values until you read them in.


@ManitobaMoose wrote:

Hi,

 

I am not sure why not.

 

Below is the code:

 

Libname Review'/folders/myfolders/Review' ;
Libname Learn'/folders/myfolders/Learn' ;  
Libname myformat'/folders/myfolders/sasuser.v94' ;
Options fmtsearch = (myformat) ;

Data review.Prob21_10 ;
    Infile '/folders/myfolders/SASData/mixed_recs.txt' pad;
    Input @16 Code 2. @ ;
        If Code eq 1 then do ;
            out = SalesReview ;
            input @1 Date mmddyy10.  
                 @ 12 Amount 4. ;
             format date mmddyy10. ;
        End ;
        Else if Code ne 1 then do ;     
            out = InventoryReview ;
            input PartNumber  $8.  
                  Quantity 8. ;  
        End ;
run ;

Data Review.SalesReview_Only ;
    Set SalesReview ;
    Select ;
        When  (Not Missing(Date))  Put Date = ;
        When (Not Missing(Amount)) Put Amount = ;
        Otherwise ;
    End ;
run ;

Data Review.InventoryReview_Only ;
    Set InventoryReview ;
    Select ;
        When  (Not Missing(Partnumber))  Put Partnumber = ;
        When (Not Missing(Quantity)) Put Quantity = ;
        Otherwise ;
    End ;
run ;

proc print data=review.Salesreview_only noobs ;
run ;

proc print data=review.Inventoryreview_only noobs ;
run ;

Below is the raw data from the infile:

10/21/2005  1001
11/15/2005  2001
A13688 250     2
B11112 300     2
01/03/2005 50001
A88778 19      2

Finally, below is the log.

 

1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
61
62 Libname Review'/folders/myfolders/Review' ;
NOTE: Libref REVIEW was successfully assigned as follows:
Engine: V9
Physical Name: /folders/myfolders/Review
63 Libname Learn'/folders/myfolders/Learn' ;
NOTE: Libref LEARN refers to the same physical library as LEARN2.
NOTE: Libref LEARN was successfully assigned as follows:
Engine: V9
Physical Name: /folders/myfolders/Learn
64 Libname myformat'/folders/myfolders/sasuser.v94' ;
NOTE: Libref MYFORMAT refers to the same physical library as SASUSER.
NOTE: Libref MYFORMAT was successfully assigned as follows:
Engine: V9
Physical Name: /folders/myfolders/sasuser.v94
65 Options fmtsearch = (myformat) ;
66
67 Data review.Prob21_10 ;
68 Infile '/folders/myfolders/SASData/mixed_recs.txt' pad;
69 Input @16 Code 2. @ ;
70 If Code eq 1 then do ;
71 out = SalesReview ;
72 input @1 Date mmddyy10.
73 @ 12 Amount 4. ;
74 format date mmddyy10. ;
75 End ;
76 Else if Code ne 1 then do ;
77 out = InventoryReview ;
78 input PartNumber  $8.
79 Quantity  8. ;
80 End ;
81 run ;
 
NOTE: Variable SalesReview is uninitialized.
NOTE: Variable InventoryReview is uninitialized.
NOTE: The infile '/folders/myfolders/SASData/mixed_recs.txt' is:
Filename=/folders/myfolders/SASData/mixed_recs.txt,
Owner Name=sasdemo,Group Name=sas,
Access Permission=-rw-rw-r--,
Last Modified=23Aug2017:10:33:41,
File Size (bytes)=106
 
NOTE: LOST CARD.
Code=2 out=. SalesReview=. Date=. Amount=. InventoryReview=. PartNumber= Quantity=. _ERROR_=1 _N_=5
NOTE: 6 records were read from the infile '/folders/myfolders/SASData/mixed_recs.txt'.
The minimum record length was 16.
The maximum record length was 16.
NOTE: SAS went to a new line when INPUT statement reached past the end of a line.
NOTE: The data set REVIEW.PROB21_10 has 4 observations and 8 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds
 
 
82
83 Data Review.SalesReview_Only ;
84 Set SalesReview ;
ERROR: File WORK.SALESREVIEW.DATA does not exist.
85 Select ;
86 When (Not Missing(Date)) Put Date = ;
87 When (Not Missing(Amount)) Put Amount = ;
88 Otherwise ;
89 End ;
90 run ;
 
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set REVIEW.SALESREVIEW_ONLY may be incomplete. When this step was stopped there were 0 observations and 2
variables.
WARNING: Data set REVIEW.SALESREVIEW_ONLY was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds
 
 
91
92 Data Review.InventoryReview_Only ;
93 Set InventoryReview ;
ERROR: File WORK.INVENTORYREVIEW.DATA does not exist.
94 Select ;
95 When (Not Missing(Partnumber)) Put Partnumber = ;
96 When (Not Missing(Quantity)) Put Quantity = ;
97 Otherwise ;
98 End ;
99 run ;
 
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set REVIEW.INVENTORYREVIEW_ONLY may be incomplete. When this step was stopped there were 0 observations and 2
variables.
WARNING: Data set REVIEW.INVENTORYREVIEW_ONLY was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
 
 
100
101 proc print data=review.Salesreview_only noobs ;
102 run ;
 
NOTE: No observations in data set REVIEW.SALESREVIEW_ONLY.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
 
 
103
104 proc print data=review.Inventoryreview_only noobs ;
105 run ;
 
NOTE: No observations in data set REVIEW.INVENTORYREVIEW_ONLY.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds
 
 
106
107
108
109
110 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;

 


 

ManitobaMoose
Quartz | Level 8

Ah yes... I forgot to include the output data sets at the top. I keep forgetting to do that for some reason. Thanks for reminding me.

 

The code below works:

 

Libname Review'/folders/myfolders/Review' ;
Libname Learn'/folders/myfolders/Learn' ;  
Libname myformat'/folders/myfolders/sasuser.v94' ; 
Options fmtsearch = (myformat) ; 

Data review.Prob21_10 salesreview(keep = date amount) inventoryreview(keep=Partnumber Quantity) ; 
	Infile '/folders/myfolders/SASData/mixed_recs.txt' pad;
	Input @16 Code 2. @ ; 
		If Code eq 1 then do ;
			output = SalesReview ;
			input @1 Date mmddyy10.  
			     @ 12 Amount 4. ; 
			 format date mmddyy10. ; 
		End ; 
		Else if Code ne 1 then do ; 	
			output = InventoryReview ;
			input @1 PartNumber  $ 6.  
			      @8 Quantity  8. ;  
		End ; 
run ; 

Data Review.SalesReview_Only ; 
	Set SalesReview ;
	Select ; 
		When  (Not Missing(Date))  Put Date = ; 
		When (Not Missing(Amount)) Put Amount = ;
		Otherwise ; 
	End ; 
run ; 

Data Review.InventoryReview_Only ; 
	Set InventoryReview ;
	Select ; 
		When  (Not Missing(Partnumber))  Put Partnumber = ; 
		When (Not Missing(Quantity)) Put Quantity = ;
		Otherwise ; 
	End ; 
run ; 

proc print data=review.Salesreview_only noobs ; 
run ; 

proc print data=review.Inventoryreview_only noobs ; 
run ;
Reeza
Super User

It shouldn't....there should be no = sign after the OUTPUT statement. 

 

OUTPUT SALESREVIEW;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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