Skip to content

Fix SAS data input alignment - remove list statement and leading whitespace#1

Draft
samiMazari with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-data-input-error
Draft

Fix SAS data input alignment - remove list statement and leading whitespace#1
samiMazari with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-data-input-error

Conversation

Copilot AI commented Dec 18, 2025

Copy link
Copy Markdown

SAS list input was misreading data values due to leading whitespace before data lines and an incorrectly placed list; statement, causing "karim" to be read into the Sexe column instead of Nom.

Changes

  • Removed list; statement - This statement was interfering with the INPUT statement's default list input behavior
  • Eliminated leading whitespace - Data lines now start at column 1, ensuring proper tokenization for space-delimited input
  • Updated to Datalines; - Replaced deprecated Cards; syntax

Example

Data menages_init;
    length Nom $ 10;
    input Nom $ Sexe $ Revenu Epargne Anciennete Statut_familial $;
    Datalines;
karim H 38.5 5.9 10 marie
fatima F 31.2 3.8 6 celib
;
Run;

With list input, SAS reads space-delimited values sequentially. Leading whitespace on data lines causes the parser to treat it as the first token, shifting all subsequent values into wrong columns.

Original prompt

Data menages_init;
length Nom $ 10;
input Nom $ Sexe $ Revenu Epargne Anciennete Statut_familial $;
list;
Cards;
karim H 38.5 5.9 10 marie
fatima F 31.2 3.8 6 celib
nassim H 27.8 2.0 4 celib
amina2 F 35.6 5.2 8 marie
tarek H 29.9 1.5 3 celib
leila F 41.3 6.7 12 marie
samir H 50.1 10.0 18 divorce
nora F 24.5 2.2 2 celib
mounir H 33.9 4.1 7 celib
luc H 42.5 5.2 12 marie
amina F 28.3 3.1 5 celib
paul H 56.7 12.4 20 marie
sarah F 37.9 7.0 10 divorce
jean H 22.4 1.2 2 celib
claire F 49.8 15.3 25 marie
youssef H 33.1 4.8 8 celib
marion F 25.6 2.5 3 celib
mohamed H 61.2 18.1 30 marie
lea F 20.3 0.7 1 celib
julien H 45.0 6.5 15 divorce
;
Run;

La j'ai le nom karim commence a partie de la 2eme colonne "sexe" et pas la 1ere colonne nom je fais quoi pour corriger ça ?
donne moi le code corrigé direct direct


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI self-assigned this Dec 18, 2025
Co-authored-by: samiMazari <124626164+samiMazari@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix input column alignment issue in data management Fix SAS data input alignment - remove list statement and leading whitespace Dec 18, 2025
Copilot AI requested a review from samiMazari December 18, 2025 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants