BookmarkSubscribeRSS Feed
CamRutherford
Fluorite | Level 6

Hello,

 

I have the below code which runs and partially works with one exception - none of the date fields are pulling through? Any reason why this would be?

 

Date fields not pulling through = Last_Deposit and Start_Date

 

DATA DEPOSIT_DATA;
ARRAY RESORT									{3} $500.;			ARRAY UNIT											{3} $500.;	
ARRAY INTERVAL_NO					{3} $500.;			ARRAY BEDS											{3} $500.;	
ARRAY MAX_OCCUPANCY		   {3} $500.;		  ARRAY PRIV_OCCUPANCY		 {3} $500.;
ARRAY OWN_KEY							  {3} $500.; 		 ARRAY RESORTNAME					{3} $500.;
ARRAY RESORTCOUNTRY			  {3} $500.; 		 ARRAY XCH_REL_NO					{3} $500.;
ARRAY START_DATE						{3} $500.;		  ARRAY LAST_DEPOSIT					{3} $500.;
FLAG=0;
DO UNTIL (LAST.SBR_ID);
SET DEPOSITS_TOP3;
BY SBR_ID;
FLAG + 1;
IF FLAG <= 3 THEN DO; RESORT{FLAG}											= RESORT_ID;				END;
IF FLAG <= 3 THEN DO; RESORTNAME{FLAG}							= RESORT_NAME;		END;
IF FLAG <= 3 THEN DO; RESORTCOUNTRY{FLAG}				  = COUNTRY;					END; 
IF FLAG <= 3 THEN DO; UNIT{FLAG}												= UNIT_NO;					END;
IF FLAG <= 3 THEN DO; INTERVAL_NO{FLAG}							 = INTERVAL;				END;
IF FLAG <= 3 THEN DO; BEDS{FLAG}												 = BED;								END;
IF FLAG <= 3 THEN DO; MAX_OCCUPANCY{FLAG}				= MAX_OCC;				END;	
IF FLAG <= 3 THEN DO; PRIV_OCCUPANCY{FLAG}				  = PRIV_OCC;				END;
IF FLAG <= 3 THEN DO; OWN_KEY{FLAG}									   = OWNERSHIP_KEY;	END;
IF FLAG <= 3 THEN DO; XCH_REL_NO{FLAG}							  = XCH_SPB_REL_NO;	END;
IF FLAG <= 3 THEN DO; START_DATE{FLAG}							  = START_DT;	END;
IF FLAG <= 3 THEN DO; LAST_DEPOSIT{FLAG}							  = LAST_DEPOSIT_DT;	END;
END;
DROP 	FLAG RESORT_ID UNIT_NO INTERVAL BED MAX_OCC PRIV_OCC OWNERSHIP_KEY RESORT_NAME COUNTRY XCH_SPB_REL_NO KEY START_DT LAST_DEPOSIT_DT SPB_TYPE ;
RUN;

 

Cheers,

Cameron

5 REPLIES 5
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Can I ask that you provide test data - in the form of a datastep - and what the output should look like.  Your code (while being hard to read) seems to be over complicated, and without the data its next to impossible to even see what is going on let alone answer the question.  At a guess your trying to transpose some data, a simpler approach is to set variable name in the dataset, then use the actual transpose procedure, far simpler.  If you provide test data (form of datastep) then can show some code.

data_null__
Jade | Level 19

What is the data type for START_DT and the other date variable?  Do you see message about conversion of numeric to character?

CamRutherford
Fluorite | Level 6

Both in DATE9 format

Shmuel
Garnet | Level 18

Excuse me but your code seems clumsy.

I have just copied your code and made aesthetic changes:

DATA DEPOSIT_DATA;
ARRAY RESORT			{3} $500.;			
ARRAY UNIT			{3} $500.;	
ARRAY INTERVAL_NO		{3} $500.;			
ARRAY BEDS			{3} $500.;	
ARRAY MAX_OCCUPANCY		{3} $500.;		  
ARRAY PRIV_OCCUPANCY    	{3} $500.;
ARRAY OWN_KEY			{3} $500.; 		 
ARRAY RESORTNAME		{3} $500.;
ARRAY RESORTCOUNTRY		{3} $500.; 		 
ARRAY XCH_REL_NO		{3} $500.;
ARRAY START_DATE		{3} $500.;		  
ARRAY LAST_DEPOSIT		{3} $500.;
FLAG=0;

DO UNTIL (LAST.SBR_ID);
 SET DEPOSITS_TOP3;
  BY SBR_ID;
	FLAG + 1;
	IF FLAG <= 3 THEN DO; 
	   RESORT{FLAG}		= RESORT_ID;		 
	   RESORTNAME{FLAG}	= RESORT_NAME;		 
	   RESORTCOUNTRY{FLAG}	= COUNTRY;			   
	   UNIT{FLAG}		= UNIT_NO;			
	   BEDS{FLAG}		= BED;				
	   MAX_OCCUPANCY{FLAG}	= MAX_OCC;				
	   PRIV_OCCUPANCY{FLAG} = PRIV_OCC;			
	   OWN_KEY{FLAG}	= OWNERSHIP_KEY;	
	   XCH_REL_NO{FLAG}	= XCH_SPB_REL_NO;	
           START_DATE{FLAG}	= START_DT;			
	   LAST_DEPOSIT{FLAG}	= LAST_DEPOSIT_DT;	
	END;
END;
DROP 	FLAG RESORT_ID UNIT_NO INTERVAL BED MAX_OCC PRIV_OCC OWNERSHIP_KEY 
        RESORT_NAME COUNTRY XCH_SPB_REL_NO KEY START_DT LAST_DEPOSIT_DT SPB_TYPE ;
RUN;

It seems that there are just two date variables:  START_DT and LAST_DEPOSIT_DT.

Are those sas date variables ? if yes then those are numeric while the appropriate arrays were defined with $ as character.

 

What is the reason you defined all arrays as $500 ? Are your variables so long ? 

ballardw
Super User

When you say 'not pulling through' do you mean that you have missing or blank values for the Start_date and Last_deposit or do you see numeric values like 20725? If you see something like 20725 it means that the value was converted from the numeric SAS date value to digits, defaulting to best. format because you did not provide any rule for the numeric to character.

You might want

START_DATE{FLAG} = put(START_DT,date9.); if you actually want a character value for date.

OR have the date arrays as numeric and assign a proper date format.

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 5 replies
  • 865 views
  • 1 like
  • 5 in conversation