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

I have this codes below. As I understand the length of item is from 1-13, IDnum is from 15-19 , Instock 21-22  backord 24-25.

the order that variable will be stored in the data is item indnum instock  backord total. But when I try on SAS program the result is iDnum  item unstuck backord total. Can anyone please help me to understand this code? 

DATA perm.update;
	INFILE invent;
	INPUT IDnum $15-19 Item $ 1-13 Instock 21-22 BackOrd 24-25;
Total = instock+backord;
RUN; 
1 ACCEPTED SOLUTION

Accepted Solutions
ed_sas_member
Meteorite | Level 14

Hi @kngu022,

 

During the compilation phase (before execution), the Program Data Vector is initialized with the variables in the order they are encountered in your code.

So in your example, the first variable name appears in the INPUT statement (IDnum), followed by Item, Instock and Backord.

In the next statement, a new variable Total is mentioned so it is finally added to this PDV.

 

15-19, etc. are just 'indicators' for SAS to find where the value of the corresponding variable is.

 

Hope this is clear.

 

Best,

 

E.g.:

DATA update1;
	INFILE datalines;
	INPUT IDnum $15-19 Item $ 1-13 Instock 21-22 BackOrd 24-25;
	Total = instock+backord;
	datalines;
AAAAAAAAAAAAA BBBBB 11 22
;
RUN; 

Capture d’écran 2020-02-15 à 19.58.05.png

View solution in original post

1 REPLY 1
ed_sas_member
Meteorite | Level 14

Hi @kngu022,

 

During the compilation phase (before execution), the Program Data Vector is initialized with the variables in the order they are encountered in your code.

So in your example, the first variable name appears in the INPUT statement (IDnum), followed by Item, Instock and Backord.

In the next statement, a new variable Total is mentioned so it is finally added to this PDV.

 

15-19, etc. are just 'indicators' for SAS to find where the value of the corresponding variable is.

 

Hope this is clear.

 

Best,

 

E.g.:

DATA update1;
	INFILE datalines;
	INPUT IDnum $15-19 Item $ 1-13 Instock 21-22 BackOrd 24-25;
	Total = instock+backord;
	datalines;
AAAAAAAAAAAAA BBBBB 11 22
;
RUN; 

Capture d’écran 2020-02-15 à 19.58.05.png

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 668 views
  • 1 like
  • 2 in conversation